import java.util.*;
import java.io.*;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		sc.close();
		long total = 0;
		for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
	
	
	
    
    
} import java.util.*; util.* java import java.io.*; io.* java class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		sc.close();
		long total = 0;
		for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		}
		if (total % 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 num = sc.nextLine();
		sc.close();
		long total = 0;
		for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	} main {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		sc.close();
		long total = 0;
		for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String num = sc.nextLine(); num sc.nextLine() sc.nextLine sc sc.close() sc.close sc long total = 0; total 0 for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		} char c num.toCharArray() num.toCharArray num {
			total += Integer.parseInt(String.valueOf(c));
		} {
			total += Integer.parseInt(String.valueOf(c));
		} total += Integer.parseInt(String.valueOf(c)) total Integer.parseInt(String.valueOf(c)) Integer.parseInt Integer String.valueOf(c) String.valueOf String c if (total % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		} total % 9 == 0 total % 9 total 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
import java.util.*;
import java.io.*;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		sc.close();
		long total = 0;
		for (char c : num.toCharArray()) {
			total += Integer.parseInt(String.valueOf(c));
		}
		if (total % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
	
	
	
    
    
}