import java.util.*;
class Main{

    public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int res =0;
    for(int i=0; i<s.length(); i++) {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    }
    if(res==0)
    System.out.println("Yes");
    else
    System.out.println("No");
     //   System.out.println("Hello World");
    }
} import java.util.*; util.* java class Main{

    public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int res =0;
    for(int i=0; i<s.length(); i++) {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    }
    if(res==0)
    System.out.println("Yes");
    else
    System.out.println("No");
     //   System.out.println("Hello World");
    }
} Main public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int res =0;
    for(int i=0; i<s.length(); i++) {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    }
    if(res==0)
    System.out.println("Yes");
    else
    System.out.println("No");
     //   System.out.println("Hello World");
    } main {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int res =0;
    for(int i=0; i<s.length(); i++) {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    }
    if(res==0)
    System.out.println("Yes");
    else
    System.out.println("No");
     //   System.out.println("Hello World");
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc int res =0; res 0 for(int i=0; i<s.length(); i++) {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    } {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    } res += (int)(s.charAt(i)-48) res (int)(s.charAt(i)-48) s.charAt(i) s.charAt s i 48 res = res%9 res res%9 res 9 if(res==0)
    System.out.println("Yes");
    else
    System.out.println("No"); res==0 res 0 System.out.println("Yes") System.out.println System.out System System.out "Yes" System.out.println("No") System.out.println System.out System System.out "No" String args[] args
import java.util.*;
class Main{

    public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int res =0;
    for(int i=0; i<s.length(); i++) {
    res += (int)(s.charAt(i)-48);
    res = res%9;
    }
    if(res==0)
    System.out.println("Yes");
    else
    System.out.println("No");
     //   System.out.println("Hello World");
    }
}
