n, k = map(int, input().split()) ans = 0; i = n+1 for v in range(n, 0, -1): if k >= v: k -= v; i = v elif i == v+1: ans += 1 print(ans)