#include <bits/stdc++.h>
using namespace std;
long long int cnt[100010];
long long int f(long long int k) {
  long long int ans = ((3 * k + 1) * k) / 2;
  return ans;
}
int main() {
  long long int n;
  cin >> n;
  long long int lo = 1, hi = 100000000, mid;
  while (hi > lo) {
    mid = (hi + lo) / 2;
    if (f(mid) > n)
      hi = mid;
    else
      lo = mid + 1;
  }
  lo--;
  long long int ind = 0, cnt = 0;
  for (int i = lo; i >= 1; i--) {
    if ((n - f(i)) % 3 == 0) {
      cnt++;
      ind = i;
      break;
    }
  }
  if (ind % 3 == 0 && ind) {
    cnt--;
  }
  cout << (ind / 3) + cnt << endl;
  return 0;
}
