n=int(input()) s=0 def su(t): k=0 for i in range(2,t): if t%i==0: k=1 break if k==0: return True else: return False for i in range(2,n): for j in range(2,n): if((su(i))and(su(j)))and(i*j==n): s=max(i,j) print(s)