#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 30;
template <class T>
vector<T> inpv(long long n, T) {
  vector<T> vt(n);
  for (long long i = 0; i < n; i++) cin >> vt[i];
  return vt;
}
template <class T>
void outv(vector<T> v, string s = " ") {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << s;
  }
}
template <class T>
void outs(set<T> v, string s = " ") {
  for (auto it = v.begin(); it != v.end(); it++) {
    cout << *it << s;
  }
}
const long long l1 = 1234567, l2 = 123456, l3 = 1234;
void f(long long x, long long r) {
  if (!x || x % l1 == 0 || x % l2 == 0 || x % l3 == 0) {
    cout << "YES";
    exit(0);
  }
  if (r > 1) return;
  if (r == 0) {
    long long q = x;
    while (q >= l1) {
      q -= l1;
      f(q, 1);
    }
  }
  while (x >= l2) {
    x -= l2;
    f(x, 2);
  }
}
int main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  long long n;
  cin >> n;
  f(n, 0);
  cout << "NO";
}
