#include <bits/stdc++.h>
using namespace std;
long long a, b, n;
bool judge(long long x) {
  long long va = a + x, vb = b + 3 * x;
  if (vb > (long long)(sqrt(n * 1.0)) || va > n) return false;
  if ((1 + vb) * vb / 2 <= va) return true;
  return false;
}
int main() {
  int i, j;
  cin >> n;
  a = n / 3 + 1;
  b = n % 3;
  b = 3 - b;
  long long ll, rr, mid;
  ll = 0;
  rr = n;
  while (ll < rr) {
    mid = (ll + rr + 1) / 2;
    if (judge(mid)) {
      ll = mid;
    } else {
      rr = mid - 1;
    }
  }
  if (judge(ll)) {
    cout << ll + 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
