import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } main {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } Scanner sn = new Scanner(System.in); sn new Scanner(System.in) String str = sn.next(); str sn.next() sn.next sn String[] strArray = new String[str.length()]; strArray new String[str.length()] str.length() str.length str long sum = 0; sum 0 for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        } int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        } {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        } sum = sum + Long.parseLong(String.valueOf(str.charAt(i))) sum sum + Long.parseLong(String.valueOf(str.charAt(i))) sum Long.parseLong(String.valueOf(str.charAt(i))) Long.parseLong Long String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i 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" String[] args args public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        String str = sn.next();
        String[] strArray = new String[str.length()];
        long sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum = sum + Long.parseLong(String.valueOf(str.charAt(i)));
        }
        if (sum % 9 == 0){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
