#yuki1176 from math import * a=int(input()) res=a for i in [2,3,5,7]: x=int(ceil(log(a,i))) res=min(res,i*x) print(res)