#include <iostream>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <bitset>
#include <type_traits>
#include <iomanip>
#include <random>
#include <chrono>
#include <functional>
#include <utility>
// avoid TLE due to I/O bottleneck
#define __FAST_IO std::ios_base::sync_with_stdio(false), \
                  std::cin.tie(nullptr), \
                  std::cout.tie(nullptr), std::cerr << std::boolalpha;
// load any type of variables from std::cin for -std=c++17
// template<typename ...Args>
// void load_vars(Args&&... args) {
//     (std::cin >> ... >> args);
// }
// load any type of variables from std::cin for -std=c++11
template <typename T>
void q_load(T& t) {
    std::cin >> t;
}
template <typename Head, typename... Tail>
void q_load(Head& H, Tail&&... T) {
  std::cin >> H;
  q_load(T...);
}
// load 1d vector
template<typename T>
void load(std::vector<T>& v) {
    for (T& x: v) std::cin >> x;
}
// load 2d unweighted graph, shift is subtracted, both is for direction
template<typename T>
void load(std::vector< std::vector<T> >& v, int n_lines,
                    int shift=0, bool both=false) {
    for (int i = 0; i < n_lines; ++i) {
        T x, y; std::cin >> x >> y;
        x -= shift; y -= shift;
        v[x].push_back(y);
        if (both) { v[y].push_back(x); }
    }
}
// load 2d weighted graph, shift is subtracted, both is for direction
template<typename T, typename S>
void load(std::vector< std::vector< std::pair<T, S> > >& v, 
                      int n_lines, int shift=0, bool both=false) {
    for (int i = 0; i < n_lines; ++i) {
        T x; S y; int z; std::cin >> x >> y >> z;
        x -= shift; y -= shift;
        v[x].push_back({y, z});
        if (both) { v[y].push_back({x, z}); }
    }
}
// load 2 parallel vectors
template<typename T, typename S>
void load(std::vector<T>& v1, std::vector<S>& v2, int n_lines) {
    for (int i = 0; i < n_lines; ++i) {
        T x; S y; std::cin >> x >> y;
        v1[i] = x;
        v2[i] = y;
    }
}
// load bit string to a bit vector
void load(std::vector<bool>& v) {
    char ch;
    for (int i = 0; i < (int)v.size(); ++i) {
        std::cin >> ch;
        v[i] = bool(ch - '0');
    }
}

// random number generator - 32 bit int
std::mt19937 rng(
    (unsigned int)(
        std::chrono::steady_clock::now().time_since_epoch().count()
    )
);
// random number generator 64 bit int
std::mt19937_64 rng_64(
    (unsigned long long)(
        std::chrono::steady_clock::now().time_since_epoch().count()
    )
);
// std::uniform_int_distribution<int\int64_t> distrib(a, b);
// distrib(rng) to get the number from [a, b]



// helpful functions
namespace ds {
// some constants, not global, use ds::
const int32_t INF_INT32 = 1e9 + 42;
const int64_t INF_INT64 = 1e18 + 300;
const int MOD = 1e9 + 7;
const long double EPS = 1e-8;


inline int gcd(int a, int b) {
    return std::__gcd(a, b);
}

int topbit(signed t){
	return t ==0 ? -1 : (31 - __builtin_clz(t));
}
int topbit(long long t){
	return t ==0 ? -1 : (63-__builtin_clzll(t));
}
int botbit(signed a){
	return a == 0? 32 : __builtin_ctz(a);
}
int botbit(long long a){
	return a == 0 ? 64 : __builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(long long t){
	return __builtin_popcountll(t);
}
bool ispow2(int i){
	return i && ( i&-i ) == i;
}
long long mask(int i){
	return (1LL << i) - 1;
}


} // end namespace ds


namespace ds{

template < typename T >
class Modular {
public:
    using Type = typename std::decay < decltype(T::value) > ::type;

    constexpr Modular(): value() {  }

    template < typename U >
    Modular(const U & x) {
        value = normalize(x);
    }

    template < typename U >
    static Type normalize(const U & x) {
        Type v;
        if (-mod() <= x && x < mod())
            v = static_cast < Type > (x);
        else
            v = static_cast < Type > (x % mod());

        if (v < 0)
            v += mod();

        return v;
    }

    const Type & operator()() const {
        return value;
    }

    template < typename U >
    explicit operator U() const {
        return static_cast < U > (value);
    }

    constexpr static Type mod() {
        return T::value;
    }

    Modular & operator += (const Modular & other) {
        if ((value += other.value) >= mod())
            value -= mod();

        return *this;
    }

    Modular & operator -= (const Modular & other) {
        if ((value -= other.value) < 0)
            value += mod();

        return *this;
    }

    template < typename U >
    Modular & operator += (const U & other) {
        return *this += Modular(other);
    }

    template < typename U >
    Modular & operator -= (const U & other) {
        return *this -= Modular(other);
    }

    Modular & operator++() {
        return *this += 1;
    }

    Modular & operator--() {
        return *this -= 1;
    }

    Modular operator++(int) {
        Modular result( * this);* this += 1;
        return result;
    }

    Modular operator--(int) {
        Modular result( * this);* this -= 1;
        return result;
    }

    Modular operator - () const {
        return Modular(-value);
    }

    template < typename U = T >
    typename std::enable_if < std::is_same < typename Modular < U > ::Type, int > ::value, Modular > ::type & operator *= (const Modular & rhs) {
        value = normalize(static_cast < int64_t > (value) * static_cast < int64_t > (rhs.value));
        return *this;
    }

    template < typename U = T >
    typename std::enable_if < std::is_same < typename Modular < U > ::Type, int64_t > ::value, Modular > ::type & operator *= (const Modular & rhs) {
        int64_t q = static_cast < int64_t > (static_cast < long double > (value) * rhs.value / mod());
        value = normalize(value * rhs.value - q * mod());
        return *this;
    }
    template < typename U = T >
    typename std::enable_if < !std::is_integral < typename Modular < U > ::Type > ::value, Modular > ::type & operator *= (const Modular & rhs) {
        value = normalize(value * rhs.value);
        return *this;
    }

    Modular inverse() const {
        Type a = value, b = mod(), u = 0, v = 1;
        while (a != 0) {
            Type t = b / a;
            b -= t * a;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        assert(b == 1);
        return Modular(u);
    }

    Modular & operator /= (const Modular & other) {
        return *this *= other.inverse();
    }

    template < typename U >
    friend bool operator == (const Modular < U > & lhs, const Modular < U > & rhs);

    template < typename U >
    friend std::istream & operator >> (std::istream & stream, Modular < U > & number);

private:
    Type value;
}; // end class Modular


// ==, !=, +, -, *, /
template < typename T >
bool operator == (const Modular < T > & lhs, const Modular < T > & rhs) {
    return lhs.value == rhs.value;
}

template < typename T, typename U >
bool operator == (const Modular < T > & lhs, U rhs) {
    return lhs == Modular < T > (rhs);
}

template < typename T, typename U >
bool operator == (U lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) == rhs;
}

template < typename T >
bool operator != (const Modular < T > & lhs, const Modular < T > & rhs) {
    return !(lhs == rhs);
}

template < typename T, typename U >
bool operator != (const Modular < T > & lhs, U rhs) {
    return !(lhs == rhs);
}

template < typename T, typename U >
bool operator != (U lhs, const Modular < T > & rhs) {
    return !(lhs == rhs);
}

template < typename T >
Modular < T > operator + (const Modular < T > & lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) += rhs;
}

template < typename T, typename U >
Modular < T > operator + (const Modular < T > & lhs, U rhs) {
    return Modular < T > (lhs) += rhs;
}

template < typename T, typename U >
Modular < T > operator + (U lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) += rhs;
}

template < typename T >
Modular < T > operator - (const Modular < T > & lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) -= rhs;
}

template < typename T, typename U >
Modular < T > operator - (const Modular < T > & lhs, U rhs) {
    return Modular < T > (lhs) -= rhs;
}

template < typename T, typename U >
Modular < T > operator - (U lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) -= rhs;
}

template < typename T >
Modular < T > operator * (const Modular < T > & lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) *= rhs;
}

template < typename T, typename U >
Modular < T > operator * (const Modular < T > & lhs, U rhs) {
    return Modular < T > (lhs) *= rhs;
}

template < typename T, typename U >
Modular < T > operator * (U lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) *= rhs;
}

template < typename T >
Modular < T > operator / (const Modular < T > & lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) /= rhs;
}

template < typename T, typename U >
Modular < T > operator / (const Modular < T > & lhs, U rhs) {
    return Modular < T > (lhs) /= rhs;
}

template < typename T, typename U >
Modular < T > operator / (U lhs, const Modular < T > & rhs) {
    return Modular < T > (lhs) /= rhs;
}

// end operator overloading

template < typename T, typename U >
Modular < T > power(const Modular < T > & a, const U & b) {
    assert(b >= 0);
    Modular < T > x = a, res = 1;
    U p = b;
    while (p > 0) {
        if (p & 1) res *= x;
        x *= x;
        p >>= 1;
    }
    return res;
}

template < typename T >
std::string to_string(const Modular < T > & number) {
    return to_string(number());
}

template < typename T >
std::ostream & operator << (std::ostream & stream,
    const Modular < T > & number) {
    return stream << number();
}

template < typename T >
std::istream & operator >> (std::istream & stream, Modular < T > & number) {
    stream >> number.value;
    number.value = Modular < T > ::normalize(number.value);
    return stream;
}


// using Mint = Modular<std::integral_constant<int, (int) 1e9 + 7>>;
// template <class T, T MOD>
// using Mint = Modular<std::integral_constant<T, MOD>>;
// constexpr int md = 998244353; // 1000000007

template<int MOD>
using Mint = Modular<std::integral_constant<int, MOD>>;

using Mint_9  = Mint<998244353>;
using Mint_10 = Mint<1000000007>;

} // end namespace ds


int main(int argc, char const *argv[])
{
    // turn_off_de_bug();
    __FAST_IO;
    
    
    char c;
    // int accum = 0;
    const int MOD = 9;
    ds::Mint<MOD> accum = 0;
    while (std::cin >> c) {
        // accum = (accum + c - '0') % 9;
        accum += c - '0';
//        debug_(c, accum)
    }
    std::cout << (accum == 0 ? "Yes": "No");
    std::cout << "\n";

      

    return 0;
}


/*
g++ b.cpp && a < input\b
submit.bat b.cpp
*/

Measured memory_bytes: 3632