d = int(input()) s = d//2 ans = d is_ok = 0 for i in range(10**7): if is_ok: break p = 0 k = s+i while k != 0: p += k k = k//2 if p == d: ans = s+i is_ok = 1 break print(ans)