import java.util.*;
import java.math.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    }

    public static void main(String[] args){
        new Main().solve();
    }
} import java.util.*; util.* java import java.math.*; math.* java public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    }

    public static void main(String[] args){
        new Main().solve();
    }
} Main void solve(){
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    } solve {
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) BigInteger n = new BigInteger(scan.next()); n new BigInteger(scan.next()) System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No") System.out.println System.out System System.out n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No" n.remainder(new BigInteger("9")).toString().equals("0") n.remainder(new BigInteger("9")).toString().equals n.remainder(new BigInteger("9")).toString() n.remainder(new BigInteger("9")).toString n.remainder(new BigInteger("9")) n.remainder n new BigInteger("9") "0" "Yes" "No" public static void main(String[] args){
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    }

    public static void main(String[] args){
        new Main().solve();
    }
} public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    }

    public static void main(String[] args){
        new Main().solve();
    }
} Main
import java.util.*;
import java.math.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        BigInteger n = new BigInteger(scan.next());
        System.out.println(n.remainder(new BigInteger("9")).toString().equals("0") ? "Yes" : "No");
    }

    public static void main(String[] args){
        new Main().solve();
    }
}
