import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    }
} Main public static void main(String[] args) {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    } main {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String         N = scan.next(); N scan.next() scan.next scan int p=0; p 0 for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
} int i=0; int i=0; i 0 i<N.length() i N.length() N.length N i++ i++ i {
    p=p+Integer.parseInt(N.substring(i,i+1));
} {
    p=p+Integer.parseInt(N.substring(i,i+1));
} p=p+Integer.parseInt(N.substring(i,i+1)) p p+Integer.parseInt(N.substring(i,i+1)) p Integer.parseInt(N.substring(i,i+1)) Integer.parseInt Integer N.substring(i,i+1) N.substring N i i+1 i 1 p=p%9 p p%9 p 9 if(p==0){System.out.println("Yes");}
else{System.out.println("No");} p==0 p 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) {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    }
} public class Main {

    public static void main(String[] args) {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here

        Scanner scan = new Scanner(System.in);
String         N = scan.next();
int p=0;
for(int i=0;i<N.length();i++){
    p=p+Integer.parseInt(N.substring(i,i+1));
}
p=p%9;
if(p==0){System.out.println("Yes");}
else{System.out.println("No");}
    }
}
