PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000085. Xếp các hàng đồng xu (Arranging Coins)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Xếp các hàng đồng xu (Arranging Coins)

Arranging Coins

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn coins, row kk requires exactly kk coins. Determine how many initial rows can be completed; a final incomplete row does not count.

Input

A single line contains nn.

Output

Print the number of complete rows.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10001\le n\le 1000.
  • Subtask 2 (30 points): 1≤n≤10000001\le n\le 1000000.
  • Subtask 3 (50 points): 1≤n≤21474836471\le n\le 2147483647.

Examples

Input

8

Output

3

Explanation

Rows 11, 22, and 33 consume 1+2+3=61+2+3=6 coins. The remaining 22 coins cannot complete row 44, so the answer is 3.