/*   @JUDGE_ID:   1705PZ   136   C */
#include <math.h>
#include <stdio.h>

int main(){
int count = 1,num;
int i,j,k;
int m = 0,n = 0,o = 0;
int next2,next3,next5;
float temp,next;
num = 1500;
while(count != num){
   next = 2;
   for(i = -m;pow(2,i) / (pow(3,n) * pow(5,o)) <= next;i++)
      for(j = -n;(pow(2,i) * pow(3,j)) / pow(5,o) <= next;j++)
	 for(k = -o;pow(2,i) * pow(3,j) * pow(5,k) <= next;k++){
            temp = pow(2,i) * pow(3,j) * pow(5,k); 
	    if(temp > 1){
	       next = temp;
	       next2 = i;
	       next3 = j;
	       next5 = k;
	       }
            }
   m += next2;
   n += next3;
   o += next5;
   count++;
   }
printf("The 1500'th ugly number is %.0f.\n",pow(2,m) * pow(3,n) * pow(5,o));
return 0;
}
@END_OF_SOURCE_CODE

