    import java.util.*;
    import java.io.*;
     
    public class Main {
      public static void main(String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      }
    } import java.util.*; util.* java import java.io.*; io.* java public class Main {
      public static void main(String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      }
    } Main public static void main(String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      } main {
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      } BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); rd new BufferedReader(new InputStreamReader(System.in)) int[] arr = new int[10]; arr new int[10] 10 String s = rd.readLine(); s rd.readLine() rd.readLine rd for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        } {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        } int val = Integer.parseInt(Character.toString(s.charAt(i))); val Integer.parseInt(Character.toString(s.charAt(i))) Integer.parseInt Integer Character.toString(s.charAt(i)) Character.toString Character s.charAt(i) s.charAt s i arr[val]++ arr[val] arr val int sum = 0; sum 0 for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i); int i = 1; int i = 1; i 1 i < 10 i 10 i++ i++ i sum += (arr[i] * i); sum += (arr[i] * i) sum (arr[i] * i) arr[i] arr i i if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No"); sum % 9 == 0 sum % 9 sum 9 0 System.out.print("Yes") System.out.print System.out System System.out "Yes" System.out.print("No") System.out.print System.out System System.out "No" String[] args args public class Main {
      public static void main(String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      }
    } public class Main {
      public static void main(String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      }
    } Main
    import java.util.*;
    import java.io.*;
     
    public class Main {
      public static void main(String[] args) throws IOException{
        BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
        int[] arr = new int[10];
        
        String s = rd.readLine();
        for (int i = 0; i < s.length(); i++) {
          int val = Integer.parseInt(Character.toString(s.charAt(i)));
          arr[val]++;
        }
        
        int sum = 0;
        for (int i = 1; i < 10; i++)
          	sum += (arr[i] * i);
        
        if (sum % 9 == 0)
          System.out.print("Yes");
        else
          System.out.print("No");
      }
    }