n = int(input()) if(n % 3 == 0 or '3' in str(n)): print("Yes") else: print("No")