#35948: python解題


11360643@me.mcu.edu.tw (11360643 11360643)


while True:
  try:
    n=int(input())
    if(n%3):print("NO")
    else:   print("YES")
  except EOFError:
    break;