
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} Main public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int s = 0; s 0 String n = sc.next(); n sc.next() sc.next sc for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		} char ch n.toCharArray() n.toCharArray n {
			s += ch - '0';
			s %= 9;
		} {
			s += ch - '0';
			s %= 9;
		} s += ch - '0' s ch - '0' ch '0' s %= 9 s 9 if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		} s == 0 s 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) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
} Main

import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int s = 0;
		String n = sc.next();
		for( char ch : n.toCharArray()) {
			s += ch - '0';
			s %= 9;
		}
		
		if( s == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}