// yukicoder@csharp

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.CompilerServices;
//using System.Web.UI;
using Debug = System.Diagnostics.Debug;
// using System.Drawing.Primitives;
//using System.Drawing;
using System.Windows;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve();
        }
    }

    //class Cout {
    //    public static Cout operator >>(
    //        Cout a, int b)
    //    {
    //        Console.WriteLine(b);
    //        return a;
    //    }
    //    //public void Cout(long a) { Console.WriteLine(a); }
    //    //public void Cout(double a) { Console.WriteLine(a); }
    //}

    class GeneralPurposeClass {
        //public const double inf = double.PositiveInfinity;
        public const long inf = 1L << 50;
        public static readonly TextWriter error = Console.Error;

        public void Rep(long n_, Action<int> action)
        {
            for (int i = 0; i < n_; i++)
            {
                action(i);
            }
        }

        public void Rep2(int a, long n_, Action<int> action)
        {
            for (int i = a; i < n_; i++)
            {
                action(i);
            }
        }

        public string ReadLine()
        {
            var s = Console.ReadLine();
            Dumpl("s", s);
            if (s.Length == 0) s = Console.ReadLine();
            var c = s[0];
            if (c == ' ' || c == '\n' || c == '\r') s = ReadLine();
            Dumpl("s", s);

            return s;
        }

        public string ReadNext()
        {
            var s = "";
            while (true)
            {
                var c = Console.Read();
                if (c != ' ' && c != '\n' && c != '\r')
                {
                    s += (char)c;
                    break;
                }
            }
            while (true)
            {
                var c = Console.Read();
                if (c == ' ' || c == '\n' || c == '\r') break;
                s += (char)c;
            }
            return s;
        }

        public long ReadLong()
        {
            return Stol(ReadNext());
        }

        public long Stol(string s)
        {
            return long.Parse(s);
        }

        public static void Write<T>(T a)
            where T : IComparable
        { Console.Write(a); }

        public static void WriteL<T>(T a)
            where T : IComparable
        { Console.WriteLine(a); }

        public static void Dump<T>(string s, T a)
            where T : IComparable
        {
#if DEBUG
            error.Write(s + ": " + a.ToString());
#endif
        }

        public static void Dumpl<T>(string s, T a)
            where T : IComparable
        {
#if DEBUG
            Dump(s, a); error.WriteLine();
#endif
        }
    }

    class Solver : GeneralPurposeClass
    {
        public void Solve()
        {
            var n = ReadLong();

            long a = inf;

            for (long i = 1; i * i <= n; i++)
            {
                if (n % i == 0) a = i;
            }
            WriteL(a + n / a  - 2);
        }
    }
}


Measured memory_bytes: 13140