N = int(input()) for n in range(N-100, N+101): if n % 2 == 0 and n % 3 == 0: print(n) break