n = int(input()) def f(n): min = n - 100 max = n + 100 for i in range(min, max+1): if i <= 3: continue if i % 2 == 0 or i % 3 == 0: return i print(f(n))