import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc int sum=0; sum 0 for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        } int i=0; int i=0; i 0 i<n.length() i n.length() n.length n i++ i++ i {
          sum += Character.getNumericValue(n.charAt(i));
        } {
          sum += Character.getNumericValue(n.charAt(i));
        } sum += Character.getNumericValue(n.charAt(i)) sum Character.getNumericValue(n.charAt(i)) Character.getNumericValue Character n.charAt(i) n.charAt n i String ans = (sum%9==0) ? "Yes" : "No"; ans (sum%9==0) ? "Yes" : "No" (sum%9==0) sum%9 sum 9 0 "Yes" "No" System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String n = sc.next();
		int sum=0;
        for (int i=0;i<n.length();i++){
          sum += Character.getNumericValue(n.charAt(i));
        }
        String ans = (sum%9==0) ? "Yes" : "No";
        // 出力
		System.out.println(ans);
	}
}