Problem:
 Score : 200 points    Problem Statement An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9 .  Determine whether N is a multiple of 9 .      Constraints  0 \leq N < 10^{200000}  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output If N is a multiple of 9 , print Yes ; otherwise, print No .        Sample Input 1 123456789      Sample Output 1 Yes  The sum of these digits is 1+2+3+4+5+6+7+8+9=45 , which is a multiple of 9 , so 123456789 is a multiple of 9 .       Sample Input 2 0      Sample Output 2 Yes       Sample Input 3 31415926535897932384626433832795028841971693993751058209749445923078164062862089986280      Sample Output 3 No

Solution (Python):
N = input()

c = 0
for i in N:
    c += int(i)

print("Yes" if c % 9 == 0 else "No")

Solution (Python):
N = list(str(input()))

total = 0
for i in range(len(N)):
    total += int(N[i])

if total % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    n = input()
    s = 0
    for c in n:
        s += int(c)
    print("Yes" if s % 9 == 0 else "No")


if __name__ == "__main__":
    main()

Solution (Python):
N = input()

ans = 0
for i in N:
    ans += int(i)
    ans %= 9

if ans == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def main():
    n = map(int, list(IS()))
    if sum(n) % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
ans = 0
for i in s:
    ans += int(i)
    ans = ans % 9

if(ans % 9 == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N = list(input().strip())
    return N,


def solve(N):
    s = sum(map(int, N))
    return "Yes" if s % 9 == 0 else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




n = list(input())[:-1]
n = [int(s) for s in n]

if sum(n) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    N = list(map(int,list(input())))
    ans = 0
    for n in N:
        ans += n
        ans %= 9
    
    if ans % 9 == 0:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Solution (Python):
N=input()
L=len(N)
count=0
for i in range(L):
    count+=int(N[i])
if count%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
def solve():
    N = input()
    sm = 0
    for i in range(len(N)):
        sm += int(N[i])
    
    if sm % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solve()

Solution (Python):
N = input()
cnt = 0

for i in range(len(N)):
    cnt += int(N[i])
if cnt % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()

l = [int(n) for n in N]
if sum(l) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input().strip()
l=len(S)
x=0
for i in range(l):
    x+=int(S[i])
if x%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import math

n=input()
s=0
for i in n:
    s+=int(i)
print("Yes" if s%9==0 else "No")

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7





N = input()
cnt = 0
for i in range(len(N)):
    cnt += int(N[i])

if cnt % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

N = len(S)

sm = 0
for i in range(N):
  sm += int(S[i])
  
if sm % 9 == 0:
  print('Yes')
else:
  print('No')

Solution (Python):
n = list(map(int, list(input())))
if sum(n) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = input()
cnt = 0
for l in n:
  cnt += int(l)
print('Yes' if cnt%9==0 else 'No')

Solution (Python):
a = input()
b = sum(map(int,a))
if b%9==0:print("Yes")
else:print("No")

Solution (Python):
n=list(input())

ans=0

for a in n:
  ans+=int(a)
  
if ans%9==0:
  print('Yes')
  
else:
  print('No')

Solution (Python):
N = list(input())

for i in range(len(N)):
    N[i] = int(N[i])

if sum(N) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
cnt = 0
for c in s:
    cnt += int(c)
print('Yes' if cnt % 9 == 0 else 'No')

Solution (Python):
N = list(input())
s = 0
for n in N:
    s += int(n)

if s%9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
if N%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = list(input())
N = list(int(n) for n in N)
s = sum(N)
if s % 9 == 0:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n = input()
l = len(n)
c = 0
for i in range(l):
    c= (c+int(n[i]))%9
f=False
if c==0:
    f=True
yn(f)

Solution (Python):
n = input()
a = 0
for i in range(len(n)):
    a += int(n[i])
if a % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

N=[int(i) for i in input()]

if sum(N)%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()
tmp = 0
for i in N:
    tmp = (tmp + int(i)) % 9
if tmp % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()

total = 0
for i in range(len(N)):
    total += int(N[i])

if total % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = input()

total = 0
for i in range(len(N)):
    total += int(N[i])

if total%9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = input()
ans = 0
for i in n:
    ans += int(i)
if ans % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()
ans = 0

for i in n:
  ans += int(i)
  ans %= 9
  
if ans % 9 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
print('Yes' if n % 9 == 0 else 'No')

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n = input().rstrip()
    ans = 0
    for i in n:
        ans += int(i)
    if ans%9==0:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Solution (Python):
N = list(input())

ans = 0

for n in N:
    ans += int(n)

if ans%9==0:
    print('Yes')
else:
    print('No')

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

Solution (Python):
import math

n = list(map(int, "".join(input())))

if sum(n) % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()
l = len(n)
ans = 0
for i in range(l):
    d = int(n[i])
    ans += d
    ans %= 9
if ans % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = input()

cnt = 0
for i in range(len(N)):
    cnt += int(N[i])
    cnt %= 9

if cnt == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin
input = stdin.readline

N = list(input().rstrip())

mod = 0

for n in N:
    mod += int(n)
    mod %= 9

print("Yes") if mod == 0 else print("No")

Solution (Python):
n = int(input())
s = str(n)
som = 0
for i in s:
    som = som+int(i)

if som%9 == 0:
    print("Yes")
    
else:
    print("No")

Solution (Python):
N = input()
sum = 0
for n in N:
    sum += int(n)
if sum % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()


    
def solve():
    s = insr()
    q = sum([int(s[i]) for i in range(len(s))])
    if q % 9 == 0:
        print("Yes")
    else:
        print("No")
    


 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 

def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Solution (Python):
def cin():  return list(map(int,input().split()))

N = input()
cnt = 0
for i in N:  cnt += int(i)
if cnt % 9 == 0:  print("Yes")
else:  print("No")

Solution (Python):
n = int(input())

def digitSum(n):
    s = str(n)
    array = list(map(int, s))
    return sum(array)

print('Yes') if digitSum(n) % 9 == 0 else print('No')

Solution (Python):
N=input()
t=0
for i in range(len(N)):
    t+=int(N[i])

print('NYoe s'[t%9==0::2])

Solution (Python):
S = input()

N = 0

for s in S:
    N += int(s)
if N % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()

if sum(int(c) for c in N) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N=list(str(input()))
total=0
for i in range(len(N)):
    total+=int(N[i])
if total%9==0:
    print('Yes')
else:
    print('No')

Solution (Python):
import math
import fractions
import collections
import itertools
N=list(input())
N=list(map(int,N))
cnt=0

if sum(N)%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: str):
    return YES if sum(map(int, N)) % 9 == 0 else NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

Solution (Python):
n = input()
total = 0 
for i in n :
    total += int(i)
if total % 9 == 0 :
    print("Yes")
else:
    print("No")

Solution (Python):
N = [int(s) for s in input()]
print('Yes' if sum(N)%9==0 else 'No')

Solution (Python):
import sys
input = sys.stdin.readline




'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
n=list(map(int, input().split()))
if sum(n)%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
if N%9 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())

if N % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()
ans = 0
for x in N:
    ans += int(x)
if ans % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        

def sosu(n):
    so = [1 for i in range(n+1)]
    so[0], so[1] = 0, 0
    for i in range(2, n+1):
        if so[i]:
            for j in range(2, n//i):
                so[i * j] = 0

    return so

def solve():
    s = getS()
    ans = 0
    for c in s:
        ans += int(c)

    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")


def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
def check():
  N = list(map(int,list(input())))
  if sum(N)%9!=0:
    return 'No'
  return 'Yes'
print(check())

Solution (Python):
N = input()

cnt = 0
for x in N:
    cnt += int(x)
if cnt % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = [int(c) for c in input()]

x = 0
for digit in s:
    x += digit

if x % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = str(input())
L = len(N)
cnt = 0
for i in range(L):
    cnt += int(N[i])
if cnt % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

n=input()
ans=0
for i in n:
  ans+=int(i)

if ans%9==0:
  print("Yes")
else:
  print("No")

Solution (Python):
n = input()
l = []
for i in n:
    l.append(int(i))

if sum(l) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = input()
tmp = 0
for i in n:
    tmp += int(i)
if tmp % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math












import sys
sys.setrecursionlimit(10000000)


mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = input()
ans = 0
for i in range(len(n)):
    ans += int(n[i])
print('Yes' if ans%9 == 0 else 'No')

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

s = list(map(int, list(input())))
tmp = sum(s)
if tmp%9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = input()
count = 0
for i in range(len(N)):
    count += int(N[i])
if count % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    S = input()

    t = 0
    for x in map(int, S):
        t += x
    print('Yes' if t % 9 == 0 else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n=input()
    sum=0
    for ni in n:
        sum+=int(ni)
    
    if sum%9==0:
        ans='Yes'
    else:
        ans='No'
    return ans

if __name__=='__main__':
    ans=main()
    print(ans)

Solution (Python):


N = input()
ans = 0
mod = 9
for k in range(len(N)):
  ans = (ans + int(N[k]))%mod
if ans == 0:
  print('Yes') 
else:
  print('No')

Solution (Python):




import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict


MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_str()
    n = n.split()
    total = 0
    for i in n:
        total += int(i)
    
    if total % 9 == 0:
        print('Yes')
    else:
        print('No')


if __name__ ==  '__main__':
    Main()

Solution (Python):

import os
import sys
from io import BytesIO, IOBase




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")


class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC
def main():

    
        
        n = input()
        ans = 0
        for i in range(len(n)):
            ans+=int(n[i])
        if(ans%9!=0):
            print("No")
        else:
            print("Yes")
        

        




        

            

        




        
        
        



        



if __name__ == "__main__":
    main()

Solution (Python):
s = input()

ans = 0

for i in s:
    ans += int(i)

if ans % 9 == 0:
    print("Yes")
else:
    print("No")