import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    }
}

class Solver {
    public String solve(String N){
        long number = 0;
        for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        }

        return number % 9 == 0 ? "Yes" : "No";
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    } main {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc System.out.println(new Solver().solve(N)) System.out.println System.out System System.out new Solver().solve(N) new Solver().solve new Solver() N String args[] args class Solver {
    public String solve(String N){
        long number = 0;
        for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        }

        return number % 9 == 0 ? "Yes" : "No";
    }
} Solver public String solve(String N){
        long number = 0;
        for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        }

        return number % 9 == 0 ? "Yes" : "No";
    } solve {
        long number = 0;
        for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        }

        return number % 9 == 0 ? "Yes" : "No";
    } long number = 0; number 0 for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        } char c N.toCharArray() N.toCharArray N {
            number += Character.getNumericValue(c);
        } {
            number += Character.getNumericValue(c);
        } number += Character.getNumericValue(c) number Character.getNumericValue(c) Character.getNumericValue Character c return number % 9 == 0 ? "Yes" : "No"; number % 9 == 0 ? "Yes" : "No" number % 9 == 0 number % 9 number 9 0 "Yes" "No" String N N public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    }
} public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        System.out.println(new Solver().solve(N));
    }
}

class Solver {
    public String solve(String N){
        long number = 0;
        for(char c: N.toCharArray()){
            number += Character.getNumericValue(c);
        }

        return number % 9 == 0 ? "Yes" : "No";
    }
}
