import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } main {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc char[] ch = new char[str.length()]; ch new char[str.length()] str.length() str.length str int[] n = new int[str.length()]; n new int[str.length()] str.length() str.length str int nSum = 0; nSum 0 for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    } {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    } ch[i] = str.charAt(i) ch[i] ch i str.charAt(i) str.charAt str i n[i] = Character.getNumericValue(ch[i]) n[i] n i Character.getNumericValue(ch[i]) Character.getNumericValue Character ch[i] ch i nSum += n[i] nSum n[i] n i if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    } nSum % 9 == 0 nSum % 9 nSum 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" String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] ch = new char[str.length()];
    int[] n = new int[str.length()];
    int nSum = 0;
    for (int i = 0; i < str.length(); i++) {
      ch[i] = str.charAt(i);
      n[i] = Character.getNumericValue(ch[i]);
      nSum += n[i];
    }
    
    if (nSum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}