def BinarySearch(yes, no, A): while abs(yes - no) != 1: mid = (yes + no)//2 if A >= 3 * mid + 3: yes = mid else: no = mid return 3 * yes + 3 A = int(input()) B = BinarySearch(-2, 10 ** 9 + 5, A) print("YES") if A == B else print("NO")