using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Numerics;
using System.Linq.Expressions;
using System.Threading;
using System.Security.Cryptography;

public static class Ex
{
    public static bool IsNullOrEmpty(this string s) { return string.IsNullOrEmpty(s); }
    public static void yesno(this bool b) => Console.WriteLine(b ? "yes" : "no");
    public static void YesNo(this bool b) => Console.WriteLine(b ? "Yes" : "No");
    public static void YESNO(this bool b) => Console.WriteLine(b ? "YES" : "NO");
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool Chmax<T>(ref this T a, T b) where T : struct, IComparable<T>
    {
        if (b.CompareTo(a) > 0) { a = b; return true; }
        else return false;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool Chmin<T>(ref this T a, T b) where T : struct, IComparable<T>
    {
        if (b.CompareTo(a) < 0) { a = b; return true; }
        else return false;
    }

    public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.OrdinalIgnoreCase); return s.ToList(); }

    public static int PopCount(this uint bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (int)((bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff));
    }
}

partial class Program
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    string GetStr() { return Console.ReadLine().Trim(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    char GetChar() { return Console.ReadLine().Trim()[0]; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    string[][] GetStrArray(int N)
    {
        var res = new string[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ');
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    int[] GetIntArray() { return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    int[][] GetIntArray(int N)
    {
        var res = new int[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public long[] GetLongArray() { return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    long[][] GetLongArray(int N)
    {
        var res = new long[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    char[] GetCharArray() { return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    double[] GetDoubleArray() { return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray(); }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    double[][] GetDoubleArray(int N)
    {
        var res = new double[N][];
        for (int i = 0; i < N; i++) res[i] = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    char[][] GetGrid(int H)
    {
        var res = new char[H][];
        for (int i = 0; i < H; i++) res[i] = Console.ReadLine().Trim().ToCharArray();
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T[] CreateArray<T>(int N, T value)
    {
        var res = new T[N];
        for (int i = 0; i < N; i++) res[i] = value;
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T[][] CreateArray<T>(int H, int W, T value)
    {
        var res = new T[H][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W];
            for (int j = 0; j < W; j++) res[i][j] = value;
        }
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T[][][] CreateArray<T>(int H, int W, int R, T value)
    {
        var res = new T[H][][];
        for (int i = 0; i < H; i++)
        {
            res[i] = new T[W][];
            for (int j = 0; j < W; j++)
            {
                res[i][j] = new T[R];
                for (int k = 0; k < R; k++) res[i][j][k] = value;
            }
        }
        return res;
    }

    Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    {
        var dic = new Dictionary<int, List<int>>();
        foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<int>()); }
        for (int i = 0; i < M; i++)
        {
            var input = GetIntArray();
            var a = isNode_0indexed ? input[0] : input[0] - 1;
            var b = isNode_0indexed ? input[1] : input[1] - 1;
            dic[a].Add(b);
            if (isDirected == false) dic[b].Add(a);
        }
        return dic;
    }
    Dictionary<int, List<(int node, long cost)>> GetWeightedAdjacencyList(int N, int M, bool isDirected, bool isNode_0indexed)
    {
        var dic = new Dictionary<int, List<(int, long)>>();
        foreach (var e in Enumerable.Range(0, N)) { dic.Add(e, new List<(int, long)>()); }
        for (int i = 0; i < M; i++)
        {
            var input = GetIntArray();
            var a = isNode_0indexed ? input[0] : input[0] - 1;
            var b = isNode_0indexed ? input[1] : input[1] - 1;
            var c = input[2];
            dic[a].Add((b, c));
            if (isDirected == false) dic[b].Add((a, c));
        }
        return dic;
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                       : eq<T, long>() ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>() ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T>(out T a) => a = cv<T>(GetStr());
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T, U>(out T a, out U b)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T, U, V>(out T a, out U b, out V c)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T, U, V, W>(out T a, out U b, out V c, out W d)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
    {
        var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Output<T>(T t) => Console.WriteLine(t);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    void Output<T>(IList<T> ls) => Console.WriteLine(string.Join(" ", ls));
    void Debug<T>(IList<IList<T>> ls)
    {
        foreach (var l in ls)
            foreach (var s in l)
                Console.WriteLine(s);
    }

    void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }

    int[] dx = new int[] { 1, 0, -1, 0, 1, -1, -1, 1 };
    int[] dy = new int[] { 0, 1, 0, -1, 1, 1, -1, -1 };
    long mod = 1000000007;
}

partial class Program
{
    static void Main()
    {
        Console.SetIn(new StreamReader(Console.OpenStandardInput(8192)));
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
        Console.Read();
    }

    public void Solve()
    {
        int n, x, pos;
        Multi(out n, out x, out pos);
        var small = x - 1;
        var big = n - x;

        int a = 0, b = 0;
        int left = 0;
        int right = n;
        while (left < right)
        {
            int middle = (left + right) / 2;
            if (middle <= pos)
            {
                b++;
                left = middle + 1;
            }
            else
            {
                a++;
                right = middle;
            }
        }
        var mc = new ModCombination(mod);
        long sum = 1;
        sum = sum * mc.Combination(small, b-1) % mod * mc.Combination(big, a) % mod;
        for (int i = 1; i <= n-a-b; i++)
        {
            sum = sum * i % mod;
        }
        for(int i = 1; i <= a; i++)
        {
            sum = sum * i % mod;
        }
        for(int i = 1; i <= b - 1; i++)
        {
            sum = sum * i % mod;
        }
        Output(sum);
    }

    public void SubSolve()
    {
    }

    class ModCombination
    {
        long mod;
        static int max = 1000000;

        long[] fac = new long[max];
        long[] finv = new long[max];
        long[] inv = new long[max];

        /// <summary>
        /// fac,finv,invの事前計算
        /// n<maxをみたすO(max)
        /// </summary>
        public ModCombination(long mod)
        {
            this.mod = mod;
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < max; i++)
            {
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        }

        /// <summary>
        /// O(1)
        /// </summary>
        public long Combination(int n, int m)
        {
            if (n < m) return 0;
            if (n < 0 || m < 0) return 0;
            return fac[n] * (finv[m] * finv[n - m] % mod) % mod;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.CodeForces._1436
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nxp = ReadInts();
            int n = nxp[0];
            int x = nxp[1];
            int p = nxp[2];

            int bottom = 0;
            int top = n;
            int upperCnt = 0;
            int lowerCnt = 0;
            while (bottom < top)
            {
                int mid = (bottom + top) / 2;
                if (mid <= p)
                {
                    bottom = mid + 1;
                    if (mid < p)
                    {
                        lowerCnt++;
                    }
                }
                else
                {
                    top = mid;
                    upperCnt++;
                }
            }

            long mask = 1000000000 + 7;
            var calculator = new CaseCalculator(mask, n);
            int lowers = x - 1;
            int uppers = n - x;
            long res = calculator.Permutation(lowers, lowerCnt);
            res *= calculator.Permutation(uppers, upperCnt);
            res %= mask;
            res *= calculator.Permutation(n -1- lowerCnt - upperCnt, n -1- lowerCnt - upperCnt);
            res %= mask;
            WriteLine(res);
        }

        class CaseCalculator
        {
            long mask;
            long[] allPermutations;
            long[] allInverses;

            public CaseCalculator(long mask, long permutationCnt)
            {
                this.mask = mask;
                allPermutations = AllPermutations(permutationCnt);
                allInverses = AllInverses(permutationCnt);
            }

            public long Combination(long n, long m)
            {
                if (n < m) return 0;

                if (n - m < m) m = n - m;

                return Multi(allPermutations[n], allInverses[n - m], allInverses[m]);
            }

            public long Permutation(long n, long m)
            {
                if (n < m) return 0;

                return Multi(allPermutations[n], allInverses[n - m]);
            }

            long[] AllPermutations(long n)
            {
                var perms = new long[n + 1];
                perms[0] = 1;
                for (int i = 1; i <= n; i++)
                {
                    perms[i] = Multi(perms[i - 1], i);
                }
                return perms;
            }

            long[] AllInverses(long n)
            {
                var inverses = new long[n + 1];
                inverses[1] = 1;
                var permInverses = new long[n + 1];
                permInverses[0] = 1;
                permInverses[1] = 1;
                for (int i = 2; i <= n; i++)
                {
                    inverses[i] = mask - inverses[mask % i] * (mask / i) % mask;
                    permInverses[i] = Multi(permInverses[i - 1], inverses[i]);
                }
                return permInverses;
            }

            public long Multi(params long[] vals)
            {
                if (vals.Length == 0)
                {
                    return 0;
                }

                long val = vals[0] % mask;
                for (int i = 1; i < vals.Length; i++)
                {
                    val *= (vals[i] % mask);
                    val %= mask;
                }
                return val;
            }

            public long Inverse(long val)
            {
                long a = mask;
                long b = val % mask;
                long x = 1;
                long x1 = 0;
                long y = 0;
                long y1 = 1;
                while (b > 0)
                {
                    long q = a / b;
                    long r = a % b;
                    long x2 = (mask + x - (q * x1) % mask) % mask;
                    long y2 = (mask + y - (q * y1) % mask) % mask;
                    a = b;
                    b = r;
                    x = x1;
                    x1 = x2;
                    y = y1;
                    y1 = y2;
                }
                return y;
            }

            long DeprecatedInverse(long val)
            {
                return Pow(val, mask - 2);
            }

            long Pow(long a, long exp)
            {
                if (exp == 0) return 1;
                else if (exp == 1) return a % mask;
                else
                {
                    long halfMod = Pow(a, exp / 2);
                    long nextMod = Multi(halfMod, halfMod);
                    if (exp % 2 == 0)
                    {
                        return nextMod;
                    }
                    else
                    {
                        return Multi(nextMod, a);
                    }
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

namespace TestProject
{
	class Program
	{
		static void Main(string[] args)
		{
			String input = null;
			String output = null;
#if LOCALTEST
			input = "../../in.txt";
			output = "../../out.txt";
#endif
			FastReader reader = new FastReader(input);
			FastWriter writer = new FastWriter(output);

			int n, m, current, previous, tu, tv;
			n = reader.nextInt();
			m = reader.nextInt();
			StringBuilder[] a = new StringBuilder[2];
			a[1] = new StringBuilder(new String('.', m));

			int[] di = { 0, 1, 0 };
			int[] dj = { 1, 0, -1 };
			int result = 0;
			for (int i = 0; i < n; ++i)
			{
				current = i % 2;
				previous = (i + 1) % 2;

				a[current] = new StringBuilder(reader.next());
				for (int u = 0; u < 2; ++u)
				{
					for (int v = 0; v < m; ++v)
					{
						if (a[u][v] == 'P')
						{
							for (int k = 0; k < di.Length; ++k)
							{
								tu = (u + di[k]) % 2;
								tv = (v + dj[k]);
								if (0 <= tv && tv < m && a[tu][tv] == 'W')
								{
									++result;
									a[u][v] = '.';
									a[tu][tv] = '.';
								}
							}
						}
					}
				}
				a[previous] = a[current];
			}
			writer.Write(result);
			//flush
			writer.Close();
		}
	}

	class FastReader
	{
		private TextReader reader = null;
		private Queue<String> q = null;

		public FastReader(String fileName)
		{
			try
			{
				if (fileName != null)
				{
					reader = new StreamReader(fileName);
				}
				else
				{
					reader = System.Console.In;
				}
			}
			catch (FileNotFoundException e)
			{
				throw e;
			}
		}

		public FastReader()
		{
			reader = System.Console.In;
		}

		public String next() {
			while (q == null || q.Count == 0)
			{
				q = new Queue<string>(reader.ReadLine().Split());
			}
			return q.Dequeue();
		}

		public int nextInt()
		{
			return Int32.Parse(next());
		}

		public long nextLong()
		{
			return Int64.Parse(next());
		}

		public double nextDouble()
		{
			return Double.Parse(next());
		}
	}

	class FastWriter
	{
		private TextWriter writer = null;

		public FastWriter (String fileName )
		{
			try
			{
				if (fileName != null)
				{
					writer = new StreamWriter(fileName);
				}
				else
				{
					writer = System.Console.Out;
				}
			}
			catch (FileNotFoundException e)
			{
				throw e;
			}
		}

		public FastWriter()
		{
			writer = System.Console.Out;
		}

		public void Write(params object[] parameters)
		{
			foreach (object o in parameters)
			{
				writer.Write(o.ToString());
			}
		}

		public void WriteLine(params object[] parameters)
		{
			foreach (object o in parameters)
			{
				writer.Write(o.ToString());
			}
			writer.WriteLine();
		}

		public void Close()
		{
			writer.Close();
		}
	}

}


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

namespace Codeforces
{
    class Program
    {
        static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static void ReadIntArray(out int[] array, char separator = ' ')
        {
            var input = Console.ReadLine().Split(separator);
            array = new int[input.Length];
            for (int i = 0; i < input.Length; i++)
            {
                array[i] = Int32.Parse(input[i]);
            }

        }
        static int ReadNextInt(string input, int index)
        {
            var ints = input.Split(' ');
            return Int32.Parse(ints[index]);
        }

        static void Main()
        {
            int res = 0;
            var input = Console.ReadLine();
            var n = ReadNextInt(input, 0);
            var m = ReadNextInt(input, 1);
            string[] table = new string[n];
            for (int i = 0; i < n; i++)
            {
                table[i] = Console.ReadLine();
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if(table[i][j] == 'W')
                    {
                        if ((i > 0 && table[i - 1][j] == 'P')
                            || (i < n - 1 && table[i + 1][j] == 'P')
                            || (j > 0 && table[i][j - 1] == 'P')
                            || (j < m - 1 && table[i][j + 1] == 'P'))
                            res++;
                    }
                }
            }
            Console.WriteLine(res);
        }
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		bool chk = false;
		for(int i=0;i<4;i++){
			if(A[i][3] == 0) continue;
			if(A[i][0] == 1 || A[i][1] == 1 || A[i][2] == 1) chk = true;
			if(A[(i+1)%4][0] == 1) chk = true;
			if(A[(i+2)%4][1] == 1) chk = true;
			if(A[(i+3)%4][2] == 1) chk = true;
		}

		Console.WriteLine(chk ? "YES" : "NO");

	}
	int[][] A;
	public Sol(){
		A = new int[4][];
		for(int i=0;i<4;i++) A[i] = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

namespace Codeforces
{
    class Program
    {
        public static void Main(string[] args)
        {
            var first = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();
            var second = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();
            var third = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();
            var fourth = Console.ReadLine().Split(' ').Select(x => Convert.ToBoolean(Convert.ToInt16(x))).ToArray();
            if (first[3] && first.Take(3).Any(x => x))
            {
                Console.WriteLine("YES");
                return;
            }
            if (second[3] && second.Take(3).Any(x => x))
            {
                Console.WriteLine("YES");
                return;
            }
            if (third[3]&& third.Take(3).Any(x => x))
            {
                Console.WriteLine("YES");
                return;
            }
            if (fourth[3] && fourth.Take(3).Any(x => x))
            {
                Console.WriteLine("YES");
                return;
            }
            if (first[0] && fourth[3] || first[1] && third[3] || first[2] && second[3] ||
                second[0] && first[3] || second[1] && fourth[3] || second[2] && third[3] ||
                third[0] && second[3] || third[1] && first[3] || third[2] && fourth[3] ||
                fourth[0] && third[3] || fourth[1] && second[3] || fourth[2] && first[3])
            {
                Console.WriteLine("YES");
                return;
            }
            Console.WriteLine("NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static void Main(string[] args)
    {
        SolveA();
    }

    private static void SolveA()
    {
        long n = RL();
        var ans = (n - 1) / 2;
        Console.WriteLine(ans);

    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

    private static long GCD(long a, long b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < g.Length; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadWord()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char[] ReadStringLine()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans == 10 || ans == 13);

        List<char> s = new List<char>();

        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while (ans != 10 && ans != 13 && ans != -1);

        return s.ToArray();
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadAnyOf(IEnumerable<char> allowed)
    {
        while (true)
        {
            char ans = (char)consoleReader.Read();
            if (allowed.Contains(ans))
                return ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(StringBuilder sb)
    {
        PushTestData(sb.ToString());
    }
    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
    #endregion
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        Console.WriteLine(n / 2 - 1 + n % 2);
    }
}


using System;

namespace Text_Document_Analysis {
    class Program {
        static void Main(string[] args) {
            Console.ReadLine();
            int pCount = 0;
            int maxLen = 0;
            int len = 0;
            bool p = false;
            foreach (char c in Console.ReadLine()) {
                if (c != '_' && c != '(' && c != ')') {
                    len++;
                } else if (len != 0) {
                    if (p) { //in parentheses
                        len = 0;
                        pCount++;
                    } else {
                        maxLen = Math.Max(len, maxLen);
                        len = 0;
                    }
                }
                if (c == '(' || c == ')') {
                    p = !p;
                }
            }
            if (len != 0) {
                if (p) { //in parentheses
                    len = 0;
                    pCount++;
                } else {
                    maxLen = Math.Max(len, maxLen);
                    len = 0;
                }
            }
            Console.Write(maxLen + " " + pCount);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        ReadInt();
        int ans1 = 0, ans2 = 0, len = 0;
        bool f = false;
        foreach (char c in ReadToken())
        {
            if (char.IsLetter(c))
            {
                len++;
                if (!f)
                    ans1 = Math.Max(ans1, len);
            }
            else
            {
                if (len > 0 && f)
                    ans2++;
                len = 0;
                if (c == '(' || c == ')')
                    f = !f;
            }
        }

        Write(ans1, ans2);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


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

namespace test2
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = Convert.ToInt32(Console.ReadLine());
            string valueStr = Console.ReadLine();
            Test(valueStr, num);
        }
        public static void Test(string valueStr, int num)
        {
            List<int> num1 = new List<int>();
            List<int> num2 = new List<int>();
            int indexOf = 0;
            string MidStr = "";
            do
            {
                int indexTwo = valueStr.IndexOf('(', indexOf);
                if (indexTwo == -1)
                {
                    indexTwo = num;
                }
                MidStr = valueStr.Substring(indexOf, indexTwo - indexOf);
                int indexThree = MidStr.IndexOf(')', 0);

                if (indexThree != -1)
                {
                    string MidStr2 = MidStr.Substring(0, indexThree);
                    insertNum(num2, MidStr2);
                    //indexOf = indexTwo + 1;
                    MidStr = MidStr.Substring(indexThree + 1);
                }
                insertNum(num1, MidStr);
                indexOf = indexTwo + 1;
                if (indexOf >= num)
                {
                    break;
                }
            } while (true);
            int[] nums = num1.ToArray();
            Array.Sort(nums);
            int num3 = 0;
            if (num1.Count != 0)
            {
                 num3 = nums[num1.Count - 1];
            }
            Console.WriteLine("{0} {1}", num3, num2.Count);
        }
        public static void insertNum(List<int> num, string MidStr)
        {
            string[] value = MidStr.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var item in value)
            {
                num.Add(item.Length);
            }
        }
    }
}


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

namespace Task
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();
            bool braces = false;
            int word = 0;
            int maxLength = 0;
            int count = 0;
            for (int i = 0; i < n; ++i)
            {
                if (input[i] == '_' && word != 0)
                {
                    //Console.WriteLine($"{i} {braces} {word} {maxLength} {count}");
                    if (braces)
                        ++count;
                    else if (maxLength < word)
                        maxLength = word;
                    word = 0;
                }
                else if (input[i] == '(')
                {
                    //Console.WriteLine($"{i} {braces} {word} {maxLength} {count}");
                    if (word != 0 && maxLength < word)
                        maxLength = word;
                    word = 0;
                    braces = true;
                }
                else if (input[i] == ')')
                {
                    //Console.WriteLine($"{i} {braces} {word} {maxLength} {count}");
                    if (word != 0)
                        ++count;
                    word = 0;
                    braces = false;
                }
                else if (input[i] != '_')
                {
                    //Console.WriteLine($"{i} {braces} {word} {maxLength} {count}");
                    ++word;
                    if (i == n - 1 && word > maxLength)
                        maxLength = word;
                }
            }
            Console.WriteLine($"{maxLength} {count}");
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF317
{
	internal class Program
	{
		private static void Main(string[] args)
		{
			var sr = new InputReader(Console.In);
			//var sr = new InputReader(new StreamReader("input.txt"));
			var task = new Task();
			using (var sw = Console.Out)
				//using (var sw = new StreamWriter("output.txt"))
			{
				task.Solve(sr, sw);
				//Console.ReadKey();
			}
		}
	}

	internal class Task
	{
		public void Solve(InputReader sr, TextWriter sw)
		{
			var n = sr.NextInt32();
			var str = sr.NextString();
			sw.Write(MaxWord(str) + " " + WordsCount(str));
		}

		private int MaxWord(string str)
		{
			var maxLen = 0;
			for (var i = 0; i < str.Length; i++) {
				if (str[i] == '(') {
					while (str[i] != ')') {
						i++;
					}
				}
				else {
					if (str[i] != '_') {
						var start = i;
						while (i < str.Length && str[i] != '(' && str[i] != '_') {
							i++;
						}
						maxLen = Math.Max(maxLen, i - start);
						i--;
					}
				}
			}

			return maxLen;
		}

		private int WordsCount(string str)
		{
			var count = 0;
			for (var i = 0; i < str.Length; i++)
			{
				if (str[i] == '(')
				{
					var j = i + 1;
					for (; j < str.Length; j++)
					{
						if (str[j] != '_' && str[j] != ')') {
							count++;
							while (j < str.Length && str[j] != '_' && str[j] != ')') {
								j++;
							}
						}
						if (j == str.Length) {
							break;
						}
						if (str[j] == ')')
						{
							break;
						}
					}
				}
			}

			return count;
		}
	}
}

internal class InputReader : IDisposable
{
	private bool isDispose;
	private readonly TextReader sr;

	public InputReader(TextReader stream)
	{
		sr = stream;
	}

	public void Dispose()
	{
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	public string NextString()
	{
		var result = sr.ReadLine();
		return result;
	}

	public int NextInt32()
	{
		return Int32.Parse(NextString());
	}

	public long NextInt64()
	{
		return Int64.Parse(NextString());
	}

	public string[] NextSplitStrings()
	{
		return NextString()
			.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
	}

	public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
	{
		return NextSplitStrings()
			.Select(s => func(s, CultureInfo.InvariantCulture))
			.ToArray();
	}

	public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
	{
		return
			str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
				.Select(s => func(s, CultureInfo.InvariantCulture))
				.ToArray();
	}

	protected void Dispose(bool dispose)
	{
		if (!isDispose) {
			if (dispose)
				sr.Close();
			isDispose = true;
		}
	}

	~InputReader()
	{
		Dispose(false);
	}
}


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

namespace CodeforcesTasks
{
    class Program_375B
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int inBrackets = 0;
            bool inbr = false;
            int len = 0;
            int maxLen = 0;

//            char[] cha = s.ToCharArray();
            foreach (char ch in s)
            {
                if (ch == '(')
                {
                    if (len > 0)
                    {
                       if (len > maxLen)
                       {
                            maxLen = len;
                        }

                        len = 0;
                    }
                    inbr = true;
                    len = 0;
                }
                if (ch == ')')
                {
                    if (len > 0)
                    {
                        inBrackets ++;
                    }
                    inbr = false;
                    len = 0;
                }
                if (Char.IsLetter(ch))
                {
                    len++;
                    if ( (!inbr) && (len > maxLen) )
                    {
                    maxLen = len;
                    }
                }
                if (ch == '_')
                {
                    if ( len > 0 )
                    {
                        if (!inbr)
                        {
                            if (len > maxLen)
                            {
                                maxLen = len;
                            }
                        }
                        else
                        {
                            inBrackets++;
                        }
                        len = 0;
                    }
                }
            }

            Console.WriteLine(maxLen + " " + inBrackets);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace Codeforces
{
    public class Program
    {
        private const int MAXN = 8000;

        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine().Trim());
            string line = Console.ReadLine();

            int maxLen = 0;
            int count = 0;

            bool insidePar = false;

            int i = 0;
            while (i < line.Length)
            {
                if (line[i] == '_')
                {
                    i++;
                }
                else if (line[i] == '(')
                {
                    insidePar = true;
                    i++;
                }
                else if (line[i] == ')')
                {
                    insidePar = false;
                    i++;
                }
                else
                {
                    int len = 0;
                    while (i < line.Length && char.IsLetter(line[i]))
                    {
                        i++;
                        len++;
                    }

                    if (insidePar)
                    {
                        count++;
                    }
                    else
                    {
                        maxLen = Math.Max(maxLen, len);
                    }

                }
            }

            Console.WriteLine(maxLen + " " + count);

        }
    }
}


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

namespace CFCSH
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s;
            s = Console.ReadLine();
            bool f = false;
            int count = 0 , M = 0 , P = 0;
            s += '_';
            for (int i = 0; i < s.Length; ++i){
                if (s[i] == '(')
                {
                    f = true;
                    if (count > M)
                        M = count;
                    count = 0;

                }
                else if (s[i] == ')')
                {
                    f = false;
                    if (count > 0)
                        ++P;
                    count = 0;
                }
                else if (s[i] == '_')
                {
                    if (count > 0)
                    {
                        if (f)
                            ++P;
                        else if (count > M)
                            M = count;
                    }
                    count = 0;

                }
                else
                    ++count;
            }
            Console.WriteLine(M + " " + P);

            }
    }
}


using System;
 class Program
    {
        public static void Main(string[] args)
        {
            int theLongestWord = 0;
            int countOfWords = 0;
            {
                bool outside = true;
                string input = Console.In.ReadToEnd().Split(new char[] { '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries)[1];
                int wrdLngth = 0;
                for (int i = 0; i < input.Length; ++i)
                {
                    if (Char.IsLetter(input[i]))
                        wrdLngth++;
                    else
                    {
                        if(wrdLngth>0)
                        {
                            if (outside)
                            {
                                if (wrdLngth > theLongestWord) theLongestWord = wrdLngth;
                            }
                            else countOfWords++;
                            wrdLngth = 0;
                        }
                        if (input[i] != '_')
                            outside = !outside;
                    }
                }
                if (wrdLngth > theLongestWord) theLongestWord = wrdLngth;
            }
            Console.Write("{0} {1}\n", theLongestWord, countOfWords);
        }
    }


using System;
using System.IO;
using System.Text;

namespace Text_Document_Analysis
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            string s = reader.ReadLine();
            s = "_" + reader.ReadLine() + "_";

            int max = 0;
            int count = 0;

            int l = 0;
            bool inner = false;
            foreach (char c in s)
            {
                if (c == '_' || c == '(' || c == ')')
                {
                    if (!inner)
                    {
                        max = Math.Max(l, max);
                    }
                    else
                    {
                        if (l > 0)
                        {
                            count++;
                        }
                    }
                    if (c == '(')
                        inner = true;
                    if (c == ')')
                        inner = false;

                    l = 0;
                }
                else
                {
                    l++;
                }
            }

            writer.Write(max);
            writer.Write(' ');
            writer.WriteLine(count);

            writer.Flush();
        }
    }
}


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

namespace Pipeline
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] input = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            if (input[0] == 1)
            {
                Console.WriteLine(0);
            }
            else if (input[0] <= input[1])
            {
                Console.WriteLine(1);
            }
            else
            {
                --input[1];
                --input[0];
                if (sum(input[1]) < input[0])
                {
                    Console.WriteLine(-1);
                }
                else
                {
                    Console.WriteLine(minSplitters(input[1], input[0]));
                }

            }
        }

        public static long sum(long n)
        {
            return (n * (n + 1)) / 2;
        }

        public static long sum(long s, long e)
        {
            if (s <= 1)
            {
                return sum(e);
            }

            return sum(e) - sum(s - 1);
        }

        public static long minSplitters(long k, long n)
        {
            long st = 1,
                en = k;
            while (st < en)
            {
                long md = (st + en) / 2;
                long s = sum(md, k);

                if (s == n)
                    return k - md + 1;
                if (s > n)
                    st = md + 1;
                else
                    en = md;
            }

            return k - st + 2;
        }
    }
}


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

namespace CodeForces
{
    class R176_Div2_B
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);

            long l=0, r, mid;
            long maxsum = (k * (k + 1) / 2) - k + 1;
            if (maxsum < n)
                r = -1;
            else
            {
                r = k - 1;
                while (l < r)
                {
                    mid = (l + r) / 2;
                    if (k * (k - 1) / 2 - (k - mid) * (k - mid - 1) / 2 + 1 < n)
                        l = mid + 1;
                    else
                        r = mid;
                }
            }
            Console.WriteLine(r);
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round78
{
    class A
    {
        struct Dice
        {
            int[] val;

            public Dice(int[] ary) { val = (int[])ary.Clone(); }

            void Rotate1()
            {
                int v = val[3];
                for (int i = 2; i >= 0; i--)
                    val[i + 1] = val[i];
                val[0] = v;
            }

            void Rotate2()
            {
                int v = val[0];
                val[0] = val[4];
                val[4] = val[2];
                val[2] = val[5];
                val[5] = v;
            }

            public int GetHash()
            {
                int bs = 1, res = 0;
                for (int i = 0; i < val.Length; i++, bs *= 8)
                    res += val[i] * bs;
                return res;
            }

            public IEnumerable<int> Rotations()
            {
                int u = GetHash();
                for (int i = 0; i < 4; i++)
                {
                    Rotate1();
                    Rotate2();
                    int v = GetHash();
                    for (int j = 0; j < 4; j++)
                    {
                        Rotate1();
                        yield return GetHash();
                    }
                    if (v != GetHash())
                        throw new Exception();
                    for (int j = 0; j < 3; j++)
                        Rotate2();
                }
                if (u != GetHash())
                    throw new Exception();
                for (int j = 0; j < 2; j++)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        Rotate1();
                        yield return GetHash();
                    }
                    for (int i = 0; i < 2; i++)
                        Rotate2();
                }
                if (u != GetHash())
                    throw new Exception();
            }
        }

        A()
        {
            var str = Console.ReadLine();
            int index = 0;
            HashSet<long> memo = new HashSet<long>();
            Dictionary<char, int> dic1 = new Dictionary<char, int>();
            for (int i = 0; i < str.Length; i++)
                if(!dic1.ContainsKey(str[i]))
                    dic1[str[i]] = index++;

            int res = 0;
            foreach (var cs in Permutations(str.ToCharArray()))
            {
                var vv = cs.Select(c => dic1[c]).ToArray();
                bool ok = true;
                foreach (var d in new Dice(vv).Rotations())
                    if (memo.Contains(d))
                    {
                        ok = false;
                        break;
                    }
                if (ok)
                {
                    //Console.WriteLine(new string(cs));
                    res++;
                    memo.Add(new Dice(vv).GetHash());
                }
            }
            Console.WriteLine(res);
        }

        static void Main()
        {
            new A();
        }

        #region Permutations
        private static void Swap<T>(T[] ts, int i, int j)
        {
            T tmp = ts[i];
            ts[i] = ts[j];
            ts[j] = tmp;
        }

        public static IEnumerable<T[]> Permutations<T>(T[] ts)
        {
            foreach (T[] p in Permutations(ts, 0, ts.Length))
            {
                yield return p;
            }
        }

        private static IEnumerable<T[]> Permutations<T>(T[] ts, int start, int end)
        {
            if (start == end) yield return ts;
            for (int i = start; i < end; i++)
            {
                for (int j = i - 1; j >= start; j--) Swap(ts, j, j + 1);
                foreach (T[] p in Permutations(ts, start + 1, end)) yield return p;
                for (int j = start; j < i; j++) Swap(ts, j, j + 1);
            }
        }
        #endregion
    }
}


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

namespace ProgrammingContest.Codeforces.Round78
{
    class A
    {
        A()
        {
            var str = Console.ReadLine();
            int index = 0;
            HashSet<long> memo = new HashSet<long>();
            Dictionary<char, int> dic1 = new Dictionary<char, int>();
            for (int i = 0; i < str.Length; i++)
                if(!dic1.ContainsKey(str[i]))
                    dic1[str[i]] = index++;

            int res = 0;
            foreach (var cs in Permutations(str.ToCharArray()))
            {
                var vv = cs.Select(c => dic1[c]).ToArray();
                bool ok = true;
                foreach (var d in new Dice(vv).Rotations())
                    if (memo.Contains(d))
                    {
                        ok = false;
                        break;
                    }
                if (ok)
                {
                    //Console.WriteLine(new string(cs));
                    res++;
                    memo.Add(new Dice(vv).GetHash());
                }
            }
            Console.WriteLine(res);
        }

        static void Main()
        {
            new A();
        }

        #region Dice
        struct Dice
        {
            /*
             * val[0]: 北
             * val[1]: 西
             * val[2]: 南
             * val[3]: 東
             * val[4]: 上
             * val[5]: 下
             */
            int[] val;

            // [0,8)
            public Dice(int[] ary) { val = (int[])ary.Clone(); }

            void Rotate(params int[] idx)
            {
                int n = idx.Length;
                int v = val[idx[0]];
                for (int i = 0; i < n - 1; i++)
                    val[idx[i]] = val[idx[i + 1]];
                val[idx[n - 1]] = v;
            }

            // 上下は変えずに、上から見て反時計回りに回転
            public void RotateZ() { Rotate(3, 2, 1, 0); }

            // 北方向に回転、東西は変わらない
            public void RotateX() { Rotate(0, 4, 2, 5); }

            // 東方向に回転、南北は変わらない
            public void RotateY() { Rotate(3, 4, 1, 5); }

            public int GetHash()
            {
                int bs = 1, res = 0;
                for (int i = 0; i < val.Length; i++, bs *= 8)
                    res += val[i] * bs;
                return res;
            }

            // Diceの回転同型を全て列挙
            public IEnumerable<int> Rotations()
            {
                for (int i = 0; i < 4; i++)
                {
                    RotateZ();
                    RotateY();
                    for (int j = 0; j < 4; j++)
                    {
                        RotateZ();
                        yield return GetHash();
                    }
                    for (int j = 0; j < 3; j++)
                        RotateY();
                }
                for (int j = 0; j < 2; j++)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        RotateZ();
                        yield return GetHash();
                    }
                    for (int i = 0; i < 2; i++)
                        RotateX();
                }
            }
        }
        #endregion
        #region Permutations
        private static void Swap<T>(T[] ts, int i, int j)
        {
            T tmp = ts[i];
            ts[i] = ts[j];
            ts[j] = tmp;
        }

        public static IEnumerable<T[]> Permutations<T>(T[] ts)
        {
            foreach (T[] p in Permutations(ts, 0, ts.Length))
            {
                yield return p;
            }
        }

        private static IEnumerable<T[]> Permutations<T>(T[] ts, int start, int end)
        {
            if (start == end) yield return ts;
            for (int i = start; i < end; i++)
            {
                for (int j = i - 1; j >= start; j--) Swap(ts, j, j + 1);
                foreach (T[] p in Permutations(ts, start + 1, end)) yield return p;
                for (int j = start; j < i; j++) Swap(ts, j, j + 1);
            }
        }
        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Threading;
using System.Collections;
using System.IO;

namespace AcmSolution
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            //Console.SetIn(new StreamReader("gcd.in"));
           // Console.SetOut(new StreamWriter("gcd.out"));
            Do();
            //Console.Out.Close();
            Console.ReadLine();
        }

        private static void Do()
        {
            int n = GetInt();
            int[] pages = GetInts();
            int sum = pages.Sum();
            int index = 1;
            if (n > sum)
            {
                for (int i = 0; i < 1000000000; i++)
                {
                    n = n - sum;
                    if (n <= sum)
                        break;
                }
            }
            for (int i = 0; i < pages.Length; i++)
            {
                n = n - pages[i];
                if (n <= 0)
                {
                    index = index + i;
                    break;
                }
            }
            Console.WriteLine(index);
        }

        #region Utils
        private const double Epsilon = 0.00000001;

        private static string GetStr()
        {
            return Console.ReadLine();
        }

        private static string[] GetStrs()
        {
            return GetStr().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] GetStrs(int cnt)
        {
            var s = new string[cnt];
            for (var i = 0; i < cnt; ++i)
                s[i] = GetStr();
            return s;
        }

        private static int GetInt()
        {
            return int.Parse(GetStr());
        }

        private static void GetInts(out int a, out int b)
        {
            var q = GetInts();
            a = q[0];
            b = q[1];
        }

        private static void GetInts(out int a, out int b, out int c)
        {
            var q = GetInts();
            a = q[0];
            b = q[1];
            c = q[2];
        }

        private static int[] GetInts()
        {
            var s = GetStrs();
            var a = new int[s.Length];
            for (var i = 0; i < s.Length; ++i)
                a[i] = int.Parse(s[i]);
            return a;
        }

        private static long GetLong()
        {
            return long.Parse(GetStr());
        }

        private static IEnumerable<long> GetLongs()
        {
            return GetStrs().Select(long.Parse);
        }

        private static void WriteDouble<T>(T d)
        {
            Console.WriteLine(string.Format("{0:0.000000000}", d).Replace(',', '.'));
        }

        private static void WL<T>(T s)
        {
            Console.WriteLine(s);
        }

        private static void W<T>(T s)
        {
            Console.Write(s);
        }

        private static void Assert(bool b)
        {
            if (!b) throw new Exception();
        }

        private static void Swap<T>(ref T a, ref T b)
        {
            var temp = a;
            a = b;
            b = temp;
        }

        #endregion
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int t = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            t %= a.Sum();
            if (t == 0)
            {
                Console.WriteLine(1 + Array.LastIndexOf(a, a.Last(x => x != 0)));
                return;
            }
            for (int i = 0; i < 7; i++)
            {
                t -= a[i];
                if (t <= 0)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
        }
    }
}


using System;
using System.Linq;

namespace _171A
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine().Split();
            var n1 = int.Parse(s[0]);
            var n2 = int.Parse(new string(s[1].Reverse().ToArray()));
            Console.WriteLine(n1+n2);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

namespace Codeforces
{
    internal class Program
    {
        private const string Test = "D1";

        private static void Solve()
        {
            var input = ReadIntArray();
            var a = input[0];
            var b = input[1];
            var res = 0;
            while (b >= 1)
            {
                res = res*10 + (b%10);
                b/=10;
            }
            res += a;
            Console.WriteLine(res);
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", Test)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static List<int> ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
            return input;
        }

        private static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static int ReadNextInt(string[] input, int index)
        {
            return Int32.Parse(input[index]);
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    int Fun(ref int x, int p)
    {
        int ret = 0;
        while (x % p == 0)
        {
            x /= p;
            ret++;
        }
        return ret;
    }

    public void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();

        int n2 = Fun(ref n, 2);
        int n3 = Fun(ref n, 3);
        int m2 = Fun(ref m, 2);
        int m3 = Fun(ref m, 3);

        if (n != m || n2 > m2 || n3 > m3)
            Write(-1);
        else
            Write(m2 - n2 + m3 - n3);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        long n = NextInt();
        long m = NextInt();
        if ((m / n) != ((m + .0) / (n + .0))) { Console.WriteLine(-1); return; }
        m /= n;
        long ans = 0;
        while (m != 1)
        {
            if (m % 3 == 0) m /= 3;
            else if (m % 2 == 0) m /= 2;
            else { Console.WriteLine(-1); return; }
            ans++;
        }
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

namespace Remove_The_Substring {
    class Program {
        static void Main( string[] args ) {
            var s = Console.ReadLine().ToArray();
            var t = Console.ReadLine().ToArray();

            var occ = new int[ t.Length ];

            var ind = Array.IndexOf( s, t[0] );
            occ[ 0 ] = ind;

            for ( var i = 1 ; i < t.Length; i++ ) {
                occ[ i ] = Array.IndexOf( s, t[ i ], occ[i-1] + 1 );
            }

            var occs = new List<List<int>>();
            occs.Add( occ.ToList() );

            for( var j = t.Length - 1; j >= 0; j-- ) {
                var next = 0;

                if( j == t.Length - 1 ) {
                    next = Array.LastIndexOf( s, t[ j ] );
                } else {
                    next = Array.LastIndexOf( s, t[ j ], occ[ j + 1 ] - 1 );
                }
                if( next != -1 && next != occ[j] ) {
                    occ[ j ] = next;
                    occs.Add( occ.ToList() );
                }
            }

            var length = 0;
            var maxLength = Math.Max( s.Length - occs[0][t.Length - 1] - 1, occs.Last().First() );

            foreach( var o in occs ) {
                for( var j = 0; j < o.Count - 1; j++ ) {
                    length = o[ j + 1 ] - o[ j ] - 1;
                    if( length > maxLength ) { maxLength = length; }
                }
            }

            Console.WriteLine( maxLength );
        }
    }
}


using System;

class Program2
    {

    static bool validate(int k, int l, char[] a, char[] b) {
        int idB = 0;
        for (int i = 0; i < k && idB< b.Length; i++) {
            if (a[i] == b[idB])
                idB++;
        }
        for (int i = l+1; i < a.Length && idB < b.Length; i++) {
            if (a[i] == b[idB])
                idB++;
        }

        return idB == b.Length;
    }

    static void Main(string[] args)
    {
        char []a = Console.ReadLine().ToCharArray();
        char []b = Console.ReadLine().ToCharArray();
        int max = 0;

        for (int i = 0; i < a.Length; i++) {
            for (int j = i; j < a.Length; j++) {
                if (validate(i, j, a, b))
                    max = Math.Max(max, j - i+1);
            }
        }

        //string[] array = aux.Split(new string[] { beta }, StringSplitOptions.None);
        //int max = 0;
        //if (array[0] != "")
        //    max = array[0].Length;

        //for (int i = 1; i < array.Length; i++) {
        //    if (array[i].Length > max)
        //        max = array[i].Length;
        //}

        Console.WriteLine(max);

    }
}


using System;
namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            long n = long.Parse(input[0]);
            long k = long.Parse(input[1]);
            bool success = true;
            for (long c = 2; c <= k; ++c) {
                if (n % c != c - 1) {
                    success = false;
                    break;
                }
            }
            if (success)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var n = long.Parse(input[0]);
            var k = long.Parse(input[1]);

            if(k >= 43)
            {
                Console.WriteLine("No");
                return;
            }

            for (var i = 1; i <= k; i++)
            {
                if (n % i != i - 1)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


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

namespace Zadanie_3
{
    class Program
    {
        public static int func(int n)
        {
            int i = 0;
            while (n > 0)
            {
                i++;
                n /= 10;
            }
            return i;
        }

        public static long mul(long n)
        {
            long res = 1;
            while(n > 0)
            {
                res *= n % 10;
                n /= 10;
            }
            return res;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int s = n.ToString().Length;// func(n);
            long ans = mul(n);
            long res = n;

            string val = "";
            for(int i = 0; i <= s; i++)
            {
                val = "0";
                for (int j = 0; j < i; j++)
                {
                    val += '9';
                }
                long pow_1 = (long)Math.Pow(10, i);
                long a = (n / pow_1 - 1) * pow_1 + long.Parse(val);
                long m = mul(a);
                if(m > ans)
                {
                    ans = m;
                    res = a;
                }
            }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


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

namespace C
{
    class Program
    {

        static void Main(string[] args)
        {
            StringBuilder n = new StringBuilder(Console.ReadLine());
            if(n.Length==1)
                Console.WriteLine(n);
            else
            {
                int max = 0;
                int res = 1;
                for(int i = 0; i<n.Length; i++)
                {
                    res *= int.Parse(n[i].ToString());
                }
                max = res;
                for(int j = n.Length-2; j>=0; j--)
                {
                    if(n[j]!='0'&&n[j]!='1')
                    {
                        n[j + 1] = '9';
                        n[j] = (int.Parse(n[j].ToString()) - 1).ToString()[0];
                        res = 1;
                        for (int i = 0; i < n.Length; i++)
                        {
                            res *= int.Parse(n[i].ToString());
                        }
                        if (res > max)
                            max = res;
                    }
                    else
                    {
                        n[j + 1] = '9';
                    }
                }
                res = 1;
                if(n[0]=='1')
                    for (int i = 1; i < n.Length; i++)
                    {
                        res *= int.Parse(n[i].ToString());
                    }
                if (res > max)
                    max = res;
                Console.WriteLine(max);
            }

        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var n = (int) ReadLong();
            for (int i = n / 2; i >= 1; i--)
            {
                var b = n - i;
                if (NOD(i, b) == 1)
                    return i + " " + b;
            }
            throw new Exception();
        }

        long NOD (long a, long b)
        {
            if (b == 0)
                return a;
            return NOD(b, a % b);
        }

        long sum(long[] prefs, int i, int j)
        {
            if (i == j)
                return 0;
            var sub = i == 0 ? 0 : prefs[i - 1];
            return prefs[j - 1] - sub;
        }

        class Vac
        {
            public long Left { get; set; }
            public long Right { get; set; }
            public long Cost { get; set; }
        }

        class End
        {
            public long Val { get; set; }
            public bool Left { get; set; }
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024 * 10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }

}


using System;
using System.Collections.Generic;
using System.Text;

namespace Day_22
{
    class Fraction
    {
        // Recursive function to
        // return gcd of a and b
        static int __gcd(int a, int b)
        {
            // Everything divides 0
            if (a == 0 || b == 0)
                return 0;

            // base case
            if (a == b)
                return a;

            // a is greater
            if (a > b)
                return __gcd(a - b, b);

            return __gcd(a, b - a);
        }

        // function to check and print if
        // two numbers are co-prime or not
        static bool coprime(int a, int b)
        {

            if (__gcd(a, b) == 1)
                return true;
            return false;
        }

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int i = n/2;
            while (i > 0)
            {
                if (coprime(i, n - i))
                {
                    Console.WriteLine($"{i} {n - i}");
                    break;
                }
                i--;
            }
        }

    }
}


using System;

namespace Problem_5_579A___A._Raising_Bacteria
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            string input = Convert.ToString(int.Parse(Console.ReadLine()), 2);
            for(int i = 0; i < input.Length; i++)
            {
                if (input[i] == '1')
                    count++;
            }
            Console.WriteLine(count);
        }
    }
}


using System;

public class Test
{
	public static void Main()
	{
		int n = int.Parse(System.Console.ReadLine());
            int c = 0;

            if (n != 0)
                while (n != 0)
                {
                    if ((n & 1) == 1)
                        c++;
                    n = n >> 1;
                }

        System.Console.WriteLine(c);
	}
}


using System;
using System.IO;
using System.Text;

namespace Shower_Line
{
    internal class Program
    {
        private static readonly StreamReader reader =
            new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);

        private static readonly StreamWriter writer =
            new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            var nn = new int[5,5];

            for (int i = 0; i < 5; i++)
            {
                string[] ss = reader.ReadLine().Split(' ');
                for (int j = 0; j < 5; j++)
                {
                    nn[i, j] = int.Parse(ss[j]);
                }
            }

            int max = 0;

            for (int i1 = 0; i1 < 5; i1++)
            {
                for (int i2 = 0; i2 < 5; i2++)
                {
                    if (i2 == i1)
                        continue;
                    for (int i3 = 0; i3 < 5; i3++)
                    {
                        if (i3 == i1 || i3 == i2)
                            continue;
                        for (int i4 = 0; i4 < 5; i4++)
                        {
                            if (i4 == i1 || i4 == i2 || i4 == i3)
                                continue;
                            for (int i5 = 0; i5 < 5; i5++)
                            {
                                if (i5 == i1 || i5 == i2 || i5 == i3 || i5 == i4)
                                    continue;
                                //(g23 + g32 + g15 + g51) + (g13 + g31 + g54 + g45) + (g15 + g51) + (g54 + g45)
                                int mm = (nn[i1, i2] + nn[i2, i1] + nn[i3, i4] + nn[i4, i3]) + (nn[i2, i3] + nn[i3, i2] + nn[i4, i5] + nn[i5, i4]) +
                                         (nn[i3, i4] + nn[i4, i3]) + (nn[i4, i5] + nn[i5, i4]);
                                if (mm > max)
                                    max = mm;
                            }
                        }
                    }
                }
            }

            writer.WriteLine("{0}", max);
            writer.Flush();
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] route=new int[5];
		for(int i=0;i<5;i++)route[i]=0;

		Max=0;
		for(int i=1;i<=5;i++){
			route[0]=i;
			dfs(route);
			route[0]=0;
		}
		Console.WriteLine("{0}",Max);
	}

	long Max;

	void dfs(int[] route_){
		int[] route=new int[5];
		int[] visit=new int[6];
		for(int i=0;i<=5;i++)visit[i]=0;
		int now=0;

		for(int i=0;i<5;i++){
			route[i]=route_[i];
			if(route[i]!=0){
				now=i;
				visit[route[i]]=1;
			}
		}

		if(now==4){
			cal(route);
			return;
		}

		for(int i=1;i<=5;i++){
			if(visit[i]==0){
				route[now+1]=i;
				dfs(route);
				route[now+1]=0;
			}
		}

		return;
	}

	void cal(int[] route){
		long sum=0;
		sum+=G[route[0]-1][route[1]-1]+G[route[1]-1][route[0]-1];
		sum+=G[route[2]-1][route[3]-1]+G[route[3]-1][route[2]-1];
		sum+=G[route[1]-1][route[2]-1]+G[route[2]-1][route[1]-1];
		sum+=G[route[3]-1][route[4]-1]+G[route[4]-1][route[3]-1];
		sum+=G[route[2]-1][route[3]-1]+G[route[3]-1][route[2]-1];
		sum+=G[route[3]-1][route[4]-1]+G[route[4]-1][route[3]-1];

		Max=Math.Max(Max,sum);
		return;
	}

	int[][] G;
	public Sol(){
		G=new int[5][];
		for(int i=0;i<5;i++)G[i]=ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}


using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Text;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Point
		{
			public int x;

			public double p;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string GetString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/

			var n = long.Parse(GetString());
			long ans = 1;
			for (long i = 1; i*i <= n; ++i)
			{
				if (n%i == 0)
				{
					long p = i;
					var can = true;
					for (long j = 2; j * j <= p; ++j)
						if (p%(j*j) == 0)
						{
							can = false;
							break;
						}
					if (can)
						ans = Math.Max(ans, p);
					p = n / i;
					can = true;
					for (long j = 2; j * j <= p; ++j)
						if (p % (j * j) == 0)
						{
							can = false;
							break;
						}
					if (can)
						ans = Math.Max(ans, p);
				}
			}
			Console.WriteLine(ans);
			/*			input.Close();
			output.Close();*/
		}
	}
}


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

namespace _326_2
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong n = Convert.ToUInt64(Console.ReadLine());
            ulong i = 2;ulong ans=1;
            bool f = false;
            ulong k= n;
            for ( i = 2; i*i <= k; i++)
            {
                if (n % i == 0)
                {
                    ans *= i;
                    while (n % i == 0) n /= i;
                }
            }
            if (n > 1) ans *= n;
            Console.WriteLine(ans);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace Test
{
    static class Program
    {
        static void Main(string[] args)
        {
            string temp = Console.ReadLine();
            List<long> temps = temp.Split(' ').Select(long.Parse).ToList();
            Console.WriteLine(Solve(temps[0], temps[1]));
        }

        static long Solve(long start, long end)
        {
            int[] segment = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
            long total = 0;
            for (long i = start; i <= end; i++)
            {
                string s = i.ToString();
                total = s.Aggregate(total, (current, t) => current + segment[int.Parse(t.ToString())]);
            }
            return total;
        }
    }
}


using System;
namespace er
{
    class Program
    {

        static void Main(string[] args)
        {

            int[] v = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

            var s = Console.ReadLine().Split(' ');
            int sum = 0;
            int a = int.Parse(s[0]);
             int b = int.Parse(s[1]);

             for (int i = a; i <=b; i++)
             {
                 string t = i.ToString();

                 for (int j = 0; j < t.Length; j++)
                 {
                     sum += v[t[j] - 48];
                 }
             }

             Console.WriteLine(sum);

        }

    }
    }


using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			string input2 = Console.ReadLine();
			string input3 = Console.ReadLine();
			string input4 = Console.ReadLine();

			//var inputs1 = input1.Split(new[] { ' ', '}', '{' , ',' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

			long n = long.Parse(input1);

			long a = long.Parse(input2);
			long b = long.Parse(input3);
			long c = long.Parse(input4);

			if (n < a && n < b)
			{
				Console.WriteLine(0);
				return;
			}

			if (a < b - c)
			{
				Console.WriteLine(n / a);
			}
			else
			{
				if (n >= b)
				{
					long diff = b - c;
					long glass = 1 + (n - b) / diff;
					long plastic = (n - glass * diff) / a;
					Console.WriteLine(glass + plastic);
				}
				else
				{
					Console.WriteLine(n / a);
				}
			}
		}

		static long Factorial(long a)
		{
			return a > 1 ? a * Factorial(a - 1) : 1;
		}
	}
}