// 提出時に消す
// package app;

import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String n = sc.next(); n sc.next() sc.next sc int check = 0; check 0 for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        } int i = 0; int i = 0; i 0 i < n.length() i n.length() n.length n i++ i++ i {
            check += Integer.valueOf(n.substring(i, i + 1));
        } {
            check += Integer.valueOf(n.substring(i, i + 1));
        } check += Integer.valueOf(n.substring(i, i + 1)) check Integer.valueOf(n.substring(i, i + 1)) Integer.valueOf Integer n.substring(i, i + 1) n.substring n i i + 1 i 1 if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } check == 0 || check % 9 == 0 check == 0 check 0 check % 9 == 0 check % 9 check 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" sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
} Main
// 提出時に消す
// package app;

import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        String n = sc.next();
        int check = 0;
        for (int i = 0; i < n.length(); i++) {
            check += Integer.valueOf(n.substring(i, i + 1));
        }

        if (check == 0 || check % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}