#include <bits/stdc++.h>
using namespace std;
long long n, ans;
bool judg(long long h) {
  if (h >= 1e6) return 0;
  long long x = (n - h * 2) / 3;
  return h * h <= 2 * x + h;
}
int main() {
  long long l, r, mid;
  scanf("%I64d", &n);
  l = 0, r = min(n / 2, 1000000LL);
  while (l < r) {
    mid = (l + r) / 2 + 1;
    if (judg(mid))
      l = mid;
    else
      r = mid - 1;
  }
  while (l && (n - l * 2) % 3) l--;
  ans = (!l ? 0 : (l - 1) / 3 + 1);
  printf("%I64d\n", ans);
  return 0;
}
