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

7a33ebd29eb31b204eb50c89178028cd99854b1c
<mask token>

<mask token>
if sum(S) % 9 == 0:
    print('Yes')
else:
    print('No')

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