if int(input())%3: print("NO") else: print("YES")