//package com.example.myPackage;

import java.util.Scanner;

public class Main {
    private  static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    }
} import java.util.Scanner; Scanner java.util public class Main {
    private  static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    }
} Main private  static Scanner s = new Scanner(System.in); s new Scanner(System.in) public static void main(String[] args) {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    } main {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    } String str = s.next(); str s.next() s.next s int size = str.length(); size str.length() str.length str long sum =0l; sum 0l for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        } int i=0; int i=0; i 0 i<size i size i++ i++ i {
            sum += ( str.charAt(i) -'0');

        } {
            sum += ( str.charAt(i) -'0');

        } sum += ( str.charAt(i) -'0') sum ( str.charAt(i) -'0') str.charAt(i) str.charAt str i '0' if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No"); sum % 9 == 0 sum % 9 sum 9 0 System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {
    private  static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    }
} public class Main {
    private  static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    }
} Main
//package com.example.myPackage;

import java.util.Scanner;

public class Main {
    private  static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {

        String str = s.next();

        int size = str.length();
        long sum =0l;
        for(int i=0;i<size;i++)
        {
            sum += ( str.charAt(i) -'0');

        }
//        System.out.println((int) str.charAt(0));
//        System.out.println(sum);
//        if(sum==0)
//            System.out.println("Yes");
//        else {
            if (sum % 9 == 0)
                System.out.println("Yes");
            else
                System.out.println("No");



    }
}
