import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    }
}

class MultipleOfNine {

    public String check(String number) {
        String[] nums = number.split("");
        long total = 0;
        for (String num : nums) {
            int parsed = Integer.parseInt(num);
            total += parsed;
        }

        if (total % 9 == 0) {
            return "Yes";
        }
        return "No";
    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    }
} Main public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    } main {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    } try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        } {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        } Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) String num = scanner.next(); num scanner.next() scanner.next scanner MultipleOfNine target = new MultipleOfNine(); target new MultipleOfNine() System.out.println(target.check(num)) System.out.println System.out System System.out target.check(num) target.check target num String[] args args class MultipleOfNine {

    public String check(String number) {
        String[] nums = number.split("");
        long total = 0;
        for (String num : nums) {
            int parsed = Integer.parseInt(num);
            total += parsed;
        }

        if (total % 9 == 0) {
            return "Yes";
        }
        return "No";
    }

} MultipleOfNine public String check(String number) {
        String[] nums = number.split("");
        long total = 0;
        for (String num : nums) {
            int parsed = Integer.parseInt(num);
            total += parsed;
        }

        if (total % 9 == 0) {
            return "Yes";
        }
        return "No";
    } check {
        String[] nums = number.split("");
        long total = 0;
        for (String num : nums) {
            int parsed = Integer.parseInt(num);
            total += parsed;
        }

        if (total % 9 == 0) {
            return "Yes";
        }
        return "No";
    } String[] nums = number.split(""); nums number.split("") number.split number "" long total = 0; total 0 for (String num : nums) {
            int parsed = Integer.parseInt(num);
            total += parsed;
        } String num nums {
            int parsed = Integer.parseInt(num);
            total += parsed;
        } {
            int parsed = Integer.parseInt(num);
            total += parsed;
        } int parsed = Integer.parseInt(num); parsed Integer.parseInt(num) Integer.parseInt Integer num total += parsed total parsed if (total % 9 == 0) {
            return "Yes";
        } total % 9 == 0 total % 9 total 9 0 {
            return "Yes";
        } return "Yes"; "Yes" return "No"; "No" String number number public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            String num = scanner.next();

            MultipleOfNine target = new MultipleOfNine();
            System.out.println(target.check(num));
        }
    }
}

class MultipleOfNine {

    public String check(String number) {
        String[] nums = number.split("");
        long total = 0;
        for (String num : nums) {
            int parsed = Integer.parseInt(num);
            total += parsed;
        }

        if (total % 9 == 0) {
            return "Yes";
        }
        return "No";
    }

}