import java.util.*; import java.io.*; public class Main { static int[] coins; static HashMap[] maps; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); coins = new int[5000]; maps = new HashMap[5000]; for (int i = 1; i < 5000; i++) { coins[i] = i * (i + 1) / 2; maps[i] = new HashMap(); } System.out.println(dfw(4999, n)); } static int dfw(int idx, int value) { if (value < 0) { return Integer.MAX_VALUE / 10; } if (value % coins[idx] == 0) { return value / coins[idx]; } if (maps[idx].containsKey(value)) { return maps[idx].get(value); } int min = Math.min(dfw(idx - 1, value), 1 + dfw(idx - 1, value - coins[idx])); maps[idx].put(value, min); return min; } }