N = eval(input())

N = list(N)

N = list(map(int, N))

if sum(N)%9 == 0:

  print("Yes")

else:

  print("No")
N = list(map(int, list(eval(input()))))

if sum(N) % 9 == 0:

  print("Yes")

else:

  print("No")

N = eval(input())
N = list(N)
N = list(map(int, N))
if sum(N) % 9 == 0:
    print("Yes")
else:
    print("No")

N = list(map(int, list(eval(input()))))
if sum(N) % 9 == 0:
    print("Yes")
else:
    print("No")

-N = eval(input()) -N = list(N) -N = list(map(int, N)) +N = list(map(int, list(eval(input()))))