#循环停止:刚好找到比a大,且符合上述剩余定理的数,循环截止 a=int(input()) b=a+1 while True: if b%3==2 and b%5==3 and b%7==2: print(b) break b+=1