import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    } main {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String N = scan.nextLine(); N scan.nextLine() scan.nextLine scan scan.close() scan.close scan int len = N.length(); len N.length() N.length N int sum = 0; sum 0 for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        } int i=0; int i=0; i 0 i<len i len i++ i++ i {
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        } {
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        } char digitChar = N.charAt(i); digitChar N.charAt(i) N.charAt N i int digitInt = Character.getNumericValue(digitChar); digitInt Character.getNumericValue(digitChar) Character.getNumericValue Character digitChar sum = sum + digitInt sum sum + digitInt sum digitInt if (sum%9==0){
            System.out.println("Yes");
            return;
        } sum%9==0 sum%9 sum 9 0 {
            System.out.println("Yes");
            return;
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; System.out.println("No") System.out.println System.out System System.out "No" return; String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String N = scan.nextLine();
        scan.close();
        int len = N.length();
        int sum = 0;
        for(int i=0;i<len;i++){
            char digitChar = N.charAt(i);
            int digitInt = Character.getNumericValue(digitChar);
            sum = sum + digitInt;
        }
        if (sum%9==0){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
        return;
    }
}
