#include <bits/stdc++.h>
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wunused-macros"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wsign-compare"
using namespace std;
static bool debug = false;
template <typename T, typename Q, typename S>
bool Bounded(const T &x, const Q &a, const S &b) {
  return a <= x && x <= b;
}
template <typename T>
int sz(const T &x) {
  return x.size();
}
template <typename T, typename Q>
bool mem(const T &s, const Q &x) {
  return s.find(x) != s.end();
}
template <typename T>
void push(vector<T> &c, const T &e) {
  c.push_back(e);
}
template <typename T>
void push(queue<T> &c, const T &e) {
  c.push(e);
}
template <typename T>
void push(set<T> &c, const T &e) {
  c.insert(e);
}
template <typename T, typename... Args>
auto emplace(vector<T> &c, Args &&...args)
    -> decltype(c.emplace_back(args...)) {
  c.emplace_back(args...);
}
template <typename T, typename... Args>
auto emplace(queue<T> &c, Args &&...args) -> decltype(c.emplace(args...)) {
  c.emplace(args...);
}
template <typename T, typename... Args>
auto emplace(set<T> &c, Args &&...args) -> decltype(c.emplace(args...)) {
  c.emplace(args...);
}
template <typename T>
void umin(T &x, const T &y) {
  x = min(x, y);
}
template <typename T>
void umax(T &x, const T &y) {
  x = max(x, y);
}
template <typename T>
int sign(const T &x) {
  return x == 0 ? 0 : x > 0 ? 1 : -1;
}
template <typename T>
T square(const T &x) {
  return x * x;
}
template <typename S, typename T>
istream &operator>>(istream &in, pair<S, T> &p) {
  return in >> p.first >> p.second;
}
template <typename T, typename I = typename T::iterator>
void read(T &cnt) {
  for (auto &x : cnt) cin >> x;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  return out << "{" << p.first << ", " << p.second << "}";
}
template <typename T>
struct show_container {
  const T &container;
  show_container(const T &container_) : container(container_) {}
};
template <typename T>
ostream &operator<<(ostream &o, const show_container<T> &thing) {
  bool first = true;
  o << "{";
  for (const auto &x : thing.container) {
    if (!first) o << ", ";
    first = false;
    o << x;
  }
  o << "}";
  return o;
}
template <typename T>
show_container<T> show(const T &container) {
  return show_container<T>(container);
}
struct dout_ {
} dout;
template <typename T>
dout_ &operator<<(dout_ &out, const T &thing) {
  if (debug) cout << thing;
  return out;
}
dout_ &operator<<(dout_ &out, ostream &(*thing)(ostream &)) {
  if (debug) cout << thing;
  return out;
}
struct outboth {
  ostream &a;
  ostream &b;
  outboth(ostream &a_, ostream &b_) : a(a_), b(b_) {}
};
template <typename T>
outboth &operator<<(outboth &both, const T &thing) {
  both.a << thing;
  both.b << thing;
  return both;
}
outboth &operator<<(outboth &both, ostream &(*thing)(ostream &)) {
  both.a << thing;
  both.b << thing;
  return both;
}
struct ScopeTiming_impl {
  string filename, function;
  int lineno;
  string label;
  int *counter;
  chrono::time_point<std::chrono::high_resolution_clock> startTime, endTime;
  ScopeTiming_impl(string filename_ = "<no file>", string function_ = "<>",
                   int lineno_ = -1, string label = "", int *counter_ = nullptr)
      : filename(filename_),
        function(function_),
        lineno(lineno_),
        label(label),
        counter(counter_) {
    startTime = std::chrono::high_resolution_clock::now();
  }
  ~ScopeTiming_impl() {
    if (!debug) return;
    endTime = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> elapsed = endTime - startTime;
    cout << filename << ":" << lineno << ":" << function;
    if (!label.empty()) cout << ":" << label;
    if (counter) cout << "[" << ++*counter << "]";
    cout << ": Time taken: ";
    int oldprec = cout.precision(3);
    auto oldflags = cout.setf(std::ios::fixed);
    cout << (1e3 * elapsed.count()) << "ms." << endl;
    cout.flags(oldflags);
    cout.precision(oldprec);
  }
};
const long long int A = 1234567, B = 123456, C = 1234;
long long int ifloor(long long int, long long int);
long long int iceil(long long int a, long long int b) {
  assert(b != 0);
  if (b < 0) b = -b, a = -a;
  if (a < 0) return -ifloor(-a, b);
  return (a + b - 1) / b;
}
long long int ifloor(long long int a, long long int b) {
  assert(b != 0);
  if (b < 0) b = -b, a = -a;
  if (a < 0) return -iceil(-a, b);
  return a / b;
}
long long int imod(long long int a, long long int b) {
  assert(b != 0);
  return a - b * ifloor(a, b);
}
long long int gcd(long long int a, long long int b) {
  a = abs(a), b = abs(b);
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b % a, a);
}
pair<long long int, long long int> egcd(long long int a, long long int b) {
  if (a < 0) {
    pair<long long int, long long int> u = egcd(-a, b);
    return pair<long long int, long long int>(-u.first, u.second);
  }
  if (b < 0) {
    pair<long long int, long long int> u = egcd(b, -a);
    return pair<long long int, long long int>(u.first, -u.second);
  }
  if (a == 0) return pair<long long int, long long int>(0, 1);
  if (b == 0) return pair<long long int, long long int>(1, 0);
  pair<long long int, long long int> u = egcd(b % a, a);
  pair<long long int, long long int> v(u.second - ifloor(b, a) * u.first,
                                       u.first);
  assert(a * v.first + b * v.second == gcd(a, b));
  return v;
}
void solve(ostream &rout) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long int N;
  cin >> N;
  if (!cin) return;
  bool done = false;
  long long int dBC = gcd(C, B);
  for (long long int a = 0; a * A <= N && !done; ++a) {
    long long int m = N - a * A;
    long long int b, c;
    tie(b, c) = egcd(B, C);
    if (m % dBC != 0) continue;
    b *= m / dBC, c *= m / dBC;
    while (b < 0) b += C / dBC, c -= B / dBC;
    if (b >= 0 && c >= 0) done = true;
  }
  rout << (done ? "YES" : "NO") << endl;
}
int main() {
  solve(cout);
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.

Kolya remembers that at the beginning of the game his game-coin score was equal to n and that he have bought only some houses (for 1 234 567 game-coins each), cars (for 123 456 game-coins each) and computers (for 1 234 game-coins each).

Kolya is now interested, whether he could have spent all of his initial n game-coins buying only houses, cars and computers or there is a bug in the game. Formally, is there a triple of non-negative integers a, b and c such that a × 1 234 567 + b × 123 456 + c × 1 234 = n?

Please help Kolya answer this question.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 109) — Kolya's initial game-coin score.

Output

Print "YES" (without quotes) if it's possible that Kolya spent all of his initial n coins buying only houses, cars and computers. Otherwise print "NO" (without quotes).

Examples

Input

1359257


Output

YES

Input

17851817


Output

NO

Note

In the first sample, one of the possible solutions is to buy one house, one car and one computer, spending 1 234 567 + 123 456 + 1234 = 1 359 257 game-coins in total.

### Response

```cpp
#include <bits/stdc++.h>
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wunused-macros"
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wsign-compare"
using namespace std;
static bool debug = false;
template <typename T, typename Q, typename S>
bool Bounded(const T &x, const Q &a, const S &b) {
  return a <= x && x <= b;
}
template <typename T>
int sz(const T &x) {
  return x.size();
}
template <typename T, typename Q>
bool mem(const T &s, const Q &x) {
  return s.find(x) != s.end();
}
template <typename T>
void push(vector<T> &c, const T &e) {
  c.push_back(e);
}
template <typename T>
void push(queue<T> &c, const T &e) {
  c.push(e);
}
template <typename T>
void push(set<T> &c, const T &e) {
  c.insert(e);
}
template <typename T, typename... Args>
auto emplace(vector<T> &c, Args &&...args)
    -> decltype(c.emplace_back(args...)) {
  c.emplace_back(args...);
}
template <typename T, typename... Args>
auto emplace(queue<T> &c, Args &&...args) -> decltype(c.emplace(args...)) {
  c.emplace(args...);
}
template <typename T, typename... Args>
auto emplace(set<T> &c, Args &&...args) -> decltype(c.emplace(args...)) {
  c.emplace(args...);
}
template <typename T>
void umin(T &x, const T &y) {
  x = min(x, y);
}
template <typename T>
void umax(T &x, const T &y) {
  x = max(x, y);
}
template <typename T>
int sign(const T &x) {
  return x == 0 ? 0 : x > 0 ? 1 : -1;
}
template <typename T>
T square(const T &x) {
  return x * x;
}
template <typename S, typename T>
istream &operator>>(istream &in, pair<S, T> &p) {
  return in >> p.first >> p.second;
}
template <typename T, typename I = typename T::iterator>
void read(T &cnt) {
  for (auto &x : cnt) cin >> x;
}
template <typename S, typename T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
  return out << "{" << p.first << ", " << p.second << "}";
}
template <typename T>
struct show_container {
  const T &container;
  show_container(const T &container_) : container(container_) {}
};
template <typename T>
ostream &operator<<(ostream &o, const show_container<T> &thing) {
  bool first = true;
  o << "{";
  for (const auto &x : thing.container) {
    if (!first) o << ", ";
    first = false;
    o << x;
  }
  o << "}";
  return o;
}
template <typename T>
show_container<T> show(const T &container) {
  return show_container<T>(container);
}
struct dout_ {
} dout;
template <typename T>
dout_ &operator<<(dout_ &out, const T &thing) {
  if (debug) cout << thing;
  return out;
}
dout_ &operator<<(dout_ &out, ostream &(*thing)(ostream &)) {
  if (debug) cout << thing;
  return out;
}
struct outboth {
  ostream &a;
  ostream &b;
  outboth(ostream &a_, ostream &b_) : a(a_), b(b_) {}
};
template <typename T>
outboth &operator<<(outboth &both, const T &thing) {
  both.a << thing;
  both.b << thing;
  return both;
}
outboth &operator<<(outboth &both, ostream &(*thing)(ostream &)) {
  both.a << thing;
  both.b << thing;
  return both;
}
struct ScopeTiming_impl {
  string filename, function;
  int lineno;
  string label;
  int *counter;
  chrono::time_point<std::chrono::high_resolution_clock> startTime, endTime;
  ScopeTiming_impl(string filename_ = "<no file>", string function_ = "<>",
                   int lineno_ = -1, string label = "", int *counter_ = nullptr)
      : filename(filename_),
        function(function_),
        lineno(lineno_),
        label(label),
        counter(counter_) {
    startTime = std::chrono::high_resolution_clock::now();
  }
  ~ScopeTiming_impl() {
    if (!debug) return;
    endTime = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> elapsed = endTime - startTime;
    cout << filename << ":" << lineno << ":" << function;
    if (!label.empty()) cout << ":" << label;
    if (counter) cout << "[" << ++*counter << "]";
    cout << ": Time taken: ";
    int oldprec = cout.precision(3);
    auto oldflags = cout.setf(std::ios::fixed);
    cout << (1e3 * elapsed.count()) << "ms." << endl;
    cout.flags(oldflags);
    cout.precision(oldprec);
  }
};
const long long int A = 1234567, B = 123456, C = 1234;
long long int ifloor(long long int, long long int);
long long int iceil(long long int a, long long int b) {
  assert(b != 0);
  if (b < 0) b = -b, a = -a;
  if (a < 0) return -ifloor(-a, b);
  return (a + b - 1) / b;
}
long long int ifloor(long long int a, long long int b) {
  assert(b != 0);
  if (b < 0) b = -b, a = -a;
  if (a < 0) return -iceil(-a, b);
  return a / b;
}
long long int imod(long long int a, long long int b) {
  assert(b != 0);
  return a - b * ifloor(a, b);
}
long long int gcd(long long int a, long long int b) {
  a = abs(a), b = abs(b);
  if (a == 0) return b;
  if (b == 0) return a;
  return gcd(b % a, a);
}
pair<long long int, long long int> egcd(long long int a, long long int b) {
  if (a < 0) {
    pair<long long int, long long int> u = egcd(-a, b);
    return pair<long long int, long long int>(-u.first, u.second);
  }
  if (b < 0) {
    pair<long long int, long long int> u = egcd(b, -a);
    return pair<long long int, long long int>(u.first, -u.second);
  }
  if (a == 0) return pair<long long int, long long int>(0, 1);
  if (b == 0) return pair<long long int, long long int>(1, 0);
  pair<long long int, long long int> u = egcd(b % a, a);
  pair<long long int, long long int> v(u.second - ifloor(b, a) * u.first,
                                       u.first);
  assert(a * v.first + b * v.second == gcd(a, b));
  return v;
}
void solve(ostream &rout) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long int N;
  cin >> N;
  if (!cin) return;
  bool done = false;
  long long int dBC = gcd(C, B);
  for (long long int a = 0; a * A <= N && !done; ++a) {
    long long int m = N - a * A;
    long long int b, c;
    tie(b, c) = egcd(B, C);
    if (m % dBC != 0) continue;
    b *= m / dBC, c *= m / dBC;
    while (b < 0) b += C / dBC, c -= B / dBC;
    if (b >= 0 && c >= 0) done = true;
  }
  rout << (done ? "YES" : "NO") << endl;
}
int main() {
  solve(cout);
  return 0;
}

```