
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/10 10:58 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    } main {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s = scanner.next(); s scanner.next() scanner.next scanner long sum = 0; sum 0 int length = s.length(); length s.length() s.length s for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        } int i = 0; int i = 0; i 0 i<length i length i++ i++ i {
            sum += (s.charAt(i)-'0');
        } {
            sum += (s.charAt(i)-'0');
        } sum += (s.charAt(i)-'0') sum (s.charAt(i)-'0') s.charAt(i) s.charAt s i '0' System.out.println(sum % 9==0?"Yes":"No") System.out.println System.out System System.out sum % 9==0?"Yes":"No" sum % 9==0 sum % 9 sum 9 0 "Yes" "No" String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    }
} Main

import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/10 10:58 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        long sum = 0;
        int length = s.length();
        for(int i = 0;i<length;i++){
            sum += (s.charAt(i)-'0');
        }
        System.out.println(sum % 9==0?"Yes":"No");
    }
}
