def solve(s):

  suma = 0

  for x in s:

    suma += int(x)

  if suma % 9 == 0:

    return True

  return False



s = eval(input())

x = solve(s)

if x == True: print("Yes")

else: print("No")
x= eval(input())

reslut = sum(list(map(int,x)))

if reslut%9 == 0 :

    print("Yes")

else:

    print('No')
def solve(s):
    suma = 0
    for x in s:
        suma += int(x)
    if suma % 9 == 0:
        return True
    return False


s = eval(input())
x = solve(s)
if x == True:
    print("Yes")
else:
    print("No")

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

-def solve(s): -    suma = 0 -    for x in s: -        suma += int(x) -    if suma % 9 == 0: -        return True -    return False - - -s = eval(input()) -x = solve(s) -if x == True: +x = eval(input()) +reslut = sum(list(map(int, x))) +if reslut % 9 == 0: