Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim ans As Long = 0
    For i As Long = Math.Floor(Math.Sqrt(n)) To 1 Step -1
      Dim m As Long = n \ i
      If m * i = n Then
        ans = m + (i - 2)
        Exit For
      End If
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class