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