using System;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;

namespace AtCoder {
    public class TestCode {
        static void Main(string[] args) {
            var N = ReadValue<string>();
            long tmp = 0;
            for(var i = 0;i < N.Length; i++) {
                var t = int.Parse(N.Substring(i,1));
                tmp += t;
            }
            if (tmp % 9 == 0) Console.Write("Yes");
            else Console.Write("No");
        }

        static T1 ReadValue<T1>() {
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            return (T1)t1.ConvertFromString(Console.ReadLine());
        }

        static (T1, T2) ReadValue<T1, T2>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]));
        }

        static (T1, T2, T3) ReadValue<T1, T2, T3>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            var t3 = TypeDescriptor.GetConverter(typeof(T3));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]),
                    (T3)t3.ConvertFromString(rl[2]));
        }

        static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            var t3 = TypeDescriptor.GetConverter(typeof(T3));
            var t4 = TypeDescriptor.GetConverter(typeof(T4));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]),
                    (T3)t3.ConvertFromString(rl[2]),
                    (T4)t4.ConvertFromString(rl[3]));
        }

        static (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            var t3 = TypeDescriptor.GetConverter(typeof(T3));
            var t4 = TypeDescriptor.GetConverter(typeof(T4));
            var t5 = TypeDescriptor.GetConverter(typeof(T5));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]),
                    (T3)t3.ConvertFromString(rl[2]),
                    (T4)t4.ConvertFromString(rl[3]),
                    (T5)t5.ConvertFromString(rl[4]));
        }

        static string[] stringArray => Console.ReadLine().Split().ToArray();
        static int[] intArray => Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
        static long[] longArray => Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
        static double[] doubleArray => Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
        static decimal[] decimalArray => Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 35556