import java.util.*;

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

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

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

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

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

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

        
    } main {
        Scanner sc = new Scanner(System.in);

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc String strN = N; strN N char[] NChar = new char[strN.length()]; NChar new char[strN.length()] strN.length() strN.length strN for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        } int i = 0; int i = 0; i 0 i<strN.length() i strN.length() strN.length strN i++ i++ i {
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        } {
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        } NChar[i] = strN.charAt(i) NChar[i] NChar i strN.charAt(i) strN.charAt strN i int[] Nint = new int[strN.length()]; Nint new int[strN.length()] strN.length() strN.length strN for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        } int j = 0; int j = 0; j 0 j<strN.length() j strN.length() strN.length strN j++ j++ j {
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        } {
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        } Nint[j] = Character.getNumericValue(NChar[j]) Nint[j] Nint j Character.getNumericValue(NChar[j]) Character.getNumericValue Character NChar[j] NChar j int sum = 0; sum 0 for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        } int k = 0; int k = 0; k 0 k<Nint.length k Nint.length Nint Nint.length k++ k++ k {
            sum += Nint[k];
        } {
            sum += Nint[k];
        } sum += Nint[k] sum Nint[k] Nint k 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("Yes") System.out.println System.out System System.out "Yes" {
            System.out.println("No");
        } System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

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

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

        
    }
} Main
import java.util.*;

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

        String N = sc.next();

        //文字列
        String strN = N;

        char[] NChar = new char[strN.length()];
        for(int i = 0; i<strN.length(); i++){
            NChar[i] = strN.charAt(i);
            //System.out.println(NChar[i]);
        }

        int[] Nint = new int[strN.length()];
        for(int j = 0; j<strN.length(); j++){
            Nint[j] = Character.getNumericValue(NChar[j]);
            //Nint[j] = NChar[j];
            //System.out.println(Nint[j]);
        }


        //ここから計算
        int sum = 0;
        //System.out.println(Nint.length);
        for(int k = 0;k<Nint.length; k++){
            sum += Nint[k];
        }

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

        
    }
}