# 入力文字を取得
input = gets

# Nを取得
N = input.to_i

i,j = 1000000000000
result = 1000000000000

for i in 2..1000000000000
    for j in 2..1000000000000
        tmp = i * j
        result = (i - 1) + (j - 1) if (tmp == N) && (tmp < result)
    end
end

# 結果を出力
print result