#include <bits/stdc++.h>
using namespace std;
long long is_possible(long long n, long long cards, int check) {
  long long temp;
  temp = (n * (n + 1)) / 2;
  temp *= 3;
  temp -= n;
  if (temp <= cards) {
    if (check == 0)
      return 1;
    else if (check == 1) {
      if ((cards - temp) % 3 == 0) {
        return 1;
      } else
        return 0;
    }
  } else
    return 0;
}
int main() {
  long long i, j, n, m, ans, high, low, mid;
  cin >> n;
  low = 0;
  high = 10000000;
  while (high - low >= 15) {
    mid = low + (high - low) / 2;
    if (is_possible(mid, n, 0) == 1)
      low = mid;
    else
      high = mid - 1;
  }
  for (i = high + 10; i >= low - 10 && i >= 0; i--) {
    if (is_possible(i, n, 1) == 1) {
      cout << (i / 3) + ((i % 3 == 0) ? (0) : (1));
      break;
    }
  }
  if (i < 0) cout << "0";
  return 0;
}
