```
class Solution(object):
def arrangeCoins(self, n):
"""
:type n: int
:rtype: int
"""
if not n:
return 0
i, j = 1, n
while i + 1 < j:
mid = (i + j) // 2
if ((1 + mid) * mid) // 2 <= n:
i = mid
else:
j = mid
return j if ((1 + j) * j) // 2 <= n else i
```