import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute20_3();
	}
	
	private static void execute20_3() {
		try (Scanner sc = new Scanner(System.in)) {
			String n = sc.next();
			
			int sum =0;
			for(int i=0;i<n.length();i++) {
				int num = Character.getNumericValue(n.charAt(i));
				sum+=num;
			}
			if(sum%9==0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
} import java.util.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Deque; Deque java.util import java.util.HashMap; HashMap java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util import java.util.Map; Map java.util import java.util.Queue; Queue java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {

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

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

	public static void main(String[] args) {
		execute20_3();
	}
	
	private static void execute20_3() {
		try (Scanner sc = new Scanner(System.in)) {
			String n = sc.next();
			
			int sum =0;
			for(int i=0;i<n.length();i++) {
				int num = Character.getNumericValue(n.charAt(i));
				sum+=num;
			}
			if(sum%9==0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
} Main
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute20_3();
	}
	
	private static void execute20_3() {
		try (Scanner sc = new Scanner(System.in)) {
			String n = sc.next();
			
			int sum =0;
			for(int i=0;i<n.length();i++) {
				int num = Character.getNumericValue(n.charAt(i));
				sum+=num;
			}
			if(sum%9==0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}