N = gets.to_i
i = 0
while true do
    i++
    l = 1
    r = 10000000000;
    while r - l > 1
        e = (l + r) / 2
        num = e * (e + 1) / 2
        if N * i < num
            l = e
        else
            r = e
        end
    end
    if(num == i * N)
        puts e
        exit
    end
end