import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    }
} Main public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    } main {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String num = scan.nextLine(); num scan.nextLine() scan.nextLine scan String[] strs = num.split(""); strs num.split("") num.split num "" int[] nums = new int[strs.length]; nums new int[strs.length] strs.length strs strs.length int sum = 0; sum 0 for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      } int i = 0; int i = 0; i 0 i < strs.length i strs.length strs strs.length i++ i++ i {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      } {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      } nums[i] = Integer.parseInt(strs[i]) nums[i] nums i Integer.parseInt(strs[i]) Integer.parseInt Integer strs[i] strs i sum += nums[i] sum nums[i] nums i if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      } sum % 9 == 0 sum % 9 sum 9 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" scan.close() scan.close scan String[] args args public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    }
} public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String num = scan.nextLine();
      String[] strs = num.split("");
      int[] nums = new int[strs.length];
      int sum = 0;
      
      for (int i = 0; i < strs.length; i++) {
        nums[i] = Integer.parseInt(strs[i]);
        sum += nums[i];
      }
      
      if (sum % 9 == 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }

      
      scan.close();
    }
}