def main():

    num = int(eval(input()))

    if num % 9 == 0:

        return 'Yes'

    else:

        return 'No'





if __name__ == '__main__':

    ans = main()

    print(ans)

def main():

    num = eval(input())

    if sum(int(c) for c in num) % 9 == 0:

        return 'Yes'

    else:

        return 'No'





if __name__ == '__main__':

    ans = main()

    print(ans)

def main():
    num = int(eval(input()))
    if num % 9 == 0:
        return "Yes"
    else:
        return "No"


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

def main():
    num = eval(input())
    if sum(int(c) for c in num) % 9 == 0:
        return "Yes"
    else:
        return "No"


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

-    num = int(eval(input())) -    if num % 9 == 0: +    num = eval(input()) +    if sum(int(c) for c in num) % 9 == 0: