import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	} main {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String s = sc.next(); s sc.next() sc.next sc long sum = 0; sum 0 while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		} s.length() > 0 s.length() s.length s 0 {
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		} sum += Integer.parseInt(s.substring(0, 1)) sum Integer.parseInt(s.substring(0, 1)) Integer.parseInt Integer s.substring(0, 1) s.substring s 0 1 s = s.substring(1) s s.substring(1) s.substring s 1 System.out.println(sum % 9 == 0 ? "Yes" : "No") System.out.println System.out System System.out sum % 9 == 0 ? "Yes" : "No" sum % 9 == 0 sum % 9 sum 9 0 "Yes" "No" String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
} Main
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		long sum = 0;
		while(s.length() > 0){
			sum += Integer.parseInt(s.substring(0, 1));
			s = s.substring(1);
		}
		
		System.out.println(sum % 9 == 0 ? "Yes" : "No");
	}
}
