#include <queue>
#include <algorithm>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

int main(){
  priority_queue<long long,vector<long long>,greater<long long> > pq;
  set<long long> s;
  pq.push(1);
  int cnt = 1;
  while (true){
    long long t = pq.top();
    pq.pop();
    ++cnt;
    if (s.find(t*2)==s.end()){
      s.insert(t*2);
      pq.push(t*2);
    }
    if (s.find(t*3)==s.end()){
      s.insert(t*3);
      pq.push(t*3);
    }
    if (s.find(t*5)==s.end()){
      s.insert(t*5);
      pq.push(t*5);
    }
    if (cnt == 1500) break;
  }
  cout << "The 1500'th ugly number is " << pq.top() << ".\n";
}
