Module _20191029

    Sub Main()
        'https://atcoder.jp/contests/abc144/tasks/abc144_c

        Dim iRead As Long = CLng(Console.ReadLine())
        Dim iOrgNumber As Long = iRead

        If iRead Mod 2 = 0 Then

            iRead -= 1

        End If

        '平方根
        Dim iKijun As Long = Math.Sqrt(iOrgNumber)

        Dim iNumber1 As Long = iKijun
        Dim iNumber2 As Long = iRead - iKijun

        Dim x As Long
        Dim y As Long

        For i As Long = iKijun To 1 Step -1

            If iOrgNumber Mod i = 0 Then

                x = i

                y = iOrgNumber \ i

                Exit For

            End If

        Next

        Console.WriteLine(x + y - 2)


    End Sub

End Module