import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    }
} Main public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    } main {
        Scanner s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) String N = s.next(); N s.next() s.next s char[] chars = N.toCharArray(); chars N.toCharArray() N.toCharArray N int n = 0; n 0 for (char aChar : chars) n += (aChar - 48); char aChar chars n += (aChar - 48); n += (aChar - 48) n (aChar - 48) aChar 48 if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No"); n % 9 == 0 n % 9 n 9 0 System.out.println("Yes") System.out.println System.out System System.out "Yes" 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 s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    }
} public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    }
} Main
import java.util.*;

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