# 정올에서 채점 받음 (http://jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=597&sca=4030)
from sys import stdin
read = lambda : stdin.readline().strip()

while True:
    n = int(read())
    if n == 0:
        break

    dp = [0 for _ in range(n)]
    dp[0] = 1

    i2 = i3 = i5 = 0
    next2, next3, next5 = 2, 3, 5
    for i in range(1, n):
        dp[i] = min(next2, next3, next5)

        if dp[i] == next2:
            i2 += 1
            next2 = dp[i2] * 2

        if dp[i] == next3:
            i3 += 1
            next3 = dp[i3] * 3

        if dp[i] == next5:
            i5 += 1
            next5 = dp[i5] * 5

    print(dp[n-1])