问题 AW: MUH and House of Cards

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:7 通过:6

题目描述

来自圣彼得堡动物园的北极熊门什科夫、乌斯拉达和来自基辅动物园的大象贺拉斯决定建造一座纸牌屋。为此,他们已经找到了一副沉重的扑克牌。让我们来描述一下他们想建造的房子:

1.这所房子由一些非零层的楼板组成。

2.每一层都由一个非零数量的房间和天花板组成。一个房间是两张相互倾斜的纸牌。房间是一排的,每个相邻的房间共用一个由另一张卡片制作的天花板。

3.除了最低的楼层外,每一层的房间都应该比下面的楼层少。

请注意,房子的尽头可能有多个房间,在这种情况下,它们也必须被天花板覆盖。此外,相邻楼层的房间数量不必相差一,差异可能更大。

当熊在练习放牌时,贺拉斯试图找出他们的房子应该有多少层组成。房子的高度是里面的楼层。你有可能用n张卡片制作很多不同高度的房子。看来大象似乎不能解决这个问题,他让你计算房子的不同高度的数量。
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards.
Let's describe the house they want to make:

  1. The house consists of some non-zero number of floors.
  2. Each floor consists of a non-zero number of rooms and the ceiling. A room is two cards that are leaned towards each other. The rooms are made in a row, each two adjoining rooms share a ceiling made by another card.
  3. Each floor besides for the lowest one should contain less rooms than the floor below.
Please note that the house may end by the floor with more than one room, and in this case they also must be covered by the ceiling. Also, the number of rooms on the adjoining floors doesn't have to differ by one, the difference may be more.
While bears are practicing to put cards, Horace tries to figure out how many floors their house should consist of. The height of the house is the number of floors in it. It is possible that you can make a lot of different houses of different heights out of n cards. It seems that the elephant cannot solve this problem and he asks you to count the number of the distinct heights of the houses that they can make using exactly n cards.
Input
The single line contains integer n (1≤n≤1012) − the number of cards.
Output
Print the number of distinct heights that the houses made of exactly n cards can have.
Examples
Input
13
Output
1
Input
6
Output
0
Note
In the first sample you can build only these two houses (remember, you must use all the cards):
Thus, 13 cards are enough only for two floor houses, so the answer is 1.
The six cards in the second sample are not enough to build any house.

输入格式

单行包含整数 n (11≤N1012 − 牌数。

输出格式

打印由 n 张卡片构成的房屋可以具有的不同高度的数量。



Examples
Input
13
Output
1
Input
6
Output
0

注意:

在第一个示例中,您只能建造这两栋房子(请记住,您必须使用所有卡片):
 因此,13 张卡片只够两层楼的房子,所以答案是 1。
第二个样本中的六张牌不足以建造任何房屋。

输入样例 复制

13

输出样例 复制

1

数据范围与提示