#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
long long n;
string st;
int main() {
  cin >> n;
  long long l = 1, r = n, ans = 0;
  while (l < r) {
    long long mid = (l + r) / 2;
    long long a_n = (mid * 3ll) - 1;
    long long sum = (2ll + a_n);
    if (2ll * n / sum >= mid)
      l = mid + 1, ans = mid;
    else
      r = mid;
  }
  if (ans == 0) {
    cout << 0;
    return 0;
  }
  while (((ans % 3) + (n % 3)) % 3) ans--;
  ans = (ans + 2) / 3;
  cout << ans << endl;
  return 0;
}
