#ifdef ONLINE_JUDGE
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
// #pragma GCC target("f16c")
// #pragma GCC target("fma", "avx2")
// #pragma GCC target("xop", "fma4")
#endif

#include <inttypes.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define Deque  std::deque
#define List   std::list
#define Map    std::map
#define Pair   std::pair
#define Queue  std::queue
#define Set    std::set
#define Stack  std::stack
#define String std::string
#define Vector std::vector

using ll  = long long;
using ull = unsigned long long;
using lf  = long double;

template <class T>
void Read(T* num) {
  T    x = 0, f = 1;
  char ch = std::getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') {
      f = -1;
    }
    ch = std::getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x  = x * 10 + ch - '0';
    ch = std::getchar();
  }
  if (num) {
    *num = x * f;
  }
  return;
}

template <>
void Read<char>(char* x) {
  std::scanf("%s", x);
  return;
}

template <class T>
void Print(T x) {
  if (x < 0) {
    std::putchar('-');
    x = -x;
  }
  if (x > 9) {
    Print(x / 10);
  }
  std::putchar(x % 10 + '0');
  return;
}

template <>
void Print<char*>(char* x) {
  std::fputs(x, stdout);
  return;
}

template <>
void Print<const char*>(const char* x) {
  std::fputs(x, stdout);
  return;
}

template <>
void Print<char>(char x) {
  std::putchar(x);
  return;
}

template <class T>
T Pow(T a, T b, const T& m) {
  a %= m;
  T res = 1;
  while (b > 0) {
    if (b & 1) {
      res = res * a % m;
    }
    a = a * a % m;
    b >>= 1;
  }
  return res;
}

template <class T>
T ExGcd(T a, T b, T* x = nullptr, T* y = nullptr) {
  if (!b) {
    if (x && y) {
      *y = 0, *x = 1;
    }
    return a;
  }
  T ans = ExGcd(b, a % b, y, x);
  if (x && y) {
    *y -= a / b * *x;
  }
  return ans;
}

#define FILE_INPUT  0
#define FILE_OUTPUT 0

void FileInputOutput() {
#if FILE_INPUT
  if (std::freopen("0.in", "r", stdin) == nullptr) {
    std::exit(-1);
  }
#endif
#if FILE_OUTPUT
  if (std::freopen("0.out", "w", stdout) == nullptr) {
    std::exit(-1);
  }
#endif
  return;
}

ll ans;

signed main() {
  FileInputOutput();

  char c;
  while (true) {
    c = getchar();
    if (c == '\n') {
      break;
    } else {
      ans += c - '0';
    }
  }
  Print(ans % 9 == 0 ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3608