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

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "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();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    } main {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String N = sc.next(); N sc.next() sc.next sc int n = 0; n 0 for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        } int i=0; int i=0; i 0 i<N.length() i N.length() N.length N i++ i++ i {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        } {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        } int num = Integer.parseInt(String.valueOf(N.charAt(i))); num Integer.parseInt(String.valueOf(N.charAt(i))) Integer.parseInt Integer String.valueOf(N.charAt(i)) String.valueOf String N.charAt(i) N.charAt N i n = (n+num)%9 n (n+num)%9 (n+num) n num 9 System.out.println((n==0) ? "Yes" : "No") System.out.println System.out System System.out (n==0) ? "Yes" : "No" (n==0) n 0 "Yes" "No" String[] args args public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    }
} public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String N = sc.next();

        int n = 0;
        for (int i=0; i<N.length(); i++) {
            int num = Integer.parseInt(String.valueOf(N.charAt(i)));
            n = (n+num)%9;
        }
        
        System.out.println((n==0) ? "Yes" : "No");
    }
}
