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

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} import java.io.*; io.* java import java.lang.*; lang.* java import java.util.*; util.* java public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    } main {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        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 int total = 0; total 0 for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        } int i = 0; int i = 0; i 0 i < num.length() i num.length() num.length num i++ i++ i {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        } {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        } total += Integer.parseInt(Character.toString(num.charAt(i))) total Integer.parseInt(Character.toString(num.charAt(i))) Integer.parseInt Integer Character.toString(num.charAt(i)) Character.toString Character num.charAt(i) num.charAt num i 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 public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
} Main
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        int total = 0;
        for (int i = 0; i < num.length(); i++) {
            total += Integer.parseInt(Character.toString(num.charAt(i)));
        }
        if (total % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}
