using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace aaa
{
	class Program
	{
		static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());

			long ans = n;

			for (long i = 1;i<=Math.Sqrt(n);i++)
			{
				if (n % i == 0)
				{
					long j = n / i;

					if (ans > i + j - 2)
					{
						ans = i + j - 2;
					}
				}
			}
			Console.Write(ans);
			Console.ReadKey(true);
		}
	}
}
