A = int(input()) if A > 3 and A % 3 == 0: print('YES') else: print('NO')