#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0, i, j, k, n, a = 1234567, b = 123456, c = 1234;
  cin >> n;
  for (i = 0; a * i <= n && !ans; i++)
    for (j = 0; a * i + b * j <= n && !ans; j++)
      if ((n - a * i - b * j) % c == 0) ans = 1;
  printf("%s\n", (ans) ? "YES" : "NO");
  return 0;
}
