using System;
using System.Linq;

namespace CodeForcesTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            int[] inputs = input.Split(' ').Select(int.Parse).ToArray();

            int i = 0;
            while (i < inputs[1])
            {
                inputs[0] = inputs[0] % 10 == 0 ? inputs[0] / 10 : inputs[0] - 1;
                i++;
            }

            Console.WriteLine(inputs[0]);
        }
    }
}


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

namespace ConsoleApplication1
{

    class Compare
    {
        private void IncAB(ref int a, ref int b)
        {
            a++;
            b++;
        }

        private bool CompareAB(int A, int B)
        {
            if (A != B)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

        public bool compares(int[] Player1, int[] Player2, int n)
        {
            int key;
            int p = 0;
            bool equil;
            for (int i = 0; i < n; ++i)
            {
                equil = true;
                key = i;
                p = 0;
                while ((key < n) && (equil))
                {
                    equil = CompareAB(Player1[key], Player2[p]);
                    IncAB(ref key, ref p);
                }
                key = 0;
                while ((key < i) && (equil))
                {
                    equil = CompareAB(Player1[key], Player2[p]);
                    IncAB(ref key, ref p);
                }
                if (equil)
                {
                    return true;
                }
            }
            return false;
        }
    }

    class ConsoleOutPut
    {
        public void No_Yes(bool answer)
        {
            if (answer)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] temp = Console.ReadLine().Split(new char[] { ' ' }, 2);
            int n = Convert.ToInt32(temp[0]);
            int L = Convert.ToInt32(temp[1]);
            int[] Player1 = new int[n];
            int[] Player2 = new int[n];
            string[] temp1 = Console.ReadLine().Split(new char[] { ' ' }, n);
            string[] temp2 = Console.ReadLine().Split(new char[] { ' ' }, n);
            for (int i = 0; i < n; i++)
            {
                Player1[i] = Convert.ToInt32(temp1[i]);
                Player2[i] = Convert.ToInt32(temp2[i]);
            }
            Compare Sasha_Kefa = new Compare();
            ConsoleOutPut WriteAnswer = new ConsoleOutPut();
            int[] Player1Points = new int[n];
            int[] Player2Points = new int[n];
            for (int i = 0; i < n - 1; ++i)
            {
                Player1Points[i] = Player1[i + 1] - Player1[i];
                Player2Points[i] = Player2[i + 1] - Player2[i];
            }
            Player1Points[n - 1] = (L - Player1[n - 1]) + Player1[0];
            Player2Points[n - 1] = (L - Player2[n - 1]) + Player2[0];
            WriteAnswer.No_Yes(Sasha_Kefa.compares(Player1Points, Player2Points, n));
        }
    }
}


using System;
using System.Linq;

namespace B_DashaAndFriends
{
    class Program
    {

        static string Get(int[] nums, int length)
        {
            var aMoved = new[] { 0 }.Concat(nums.Skip(1).Select(d => d - nums[0])).Concat(new [] {length});

            var diffs = aMoved.Zip(aMoved.Skip(1), (a, b) => b - a).ToArray();

            var aString = string.Join("", diffs);

            return aString;
        }

        static void Main()
        {
            var nums =
                Console.ReadLine()
                    .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(int.Parse)
                    .ToArray();

            var obstacles = nums[0];
            var length = nums[1];

            var aDistances = Console.ReadLine()
                    .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(int.Parse)
                    .ToArray();

            var bDistances = Console.ReadLine()
                    .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(int.Parse)
                    .ToArray();

            var aMoved = new[] {0}.Concat(aDistances.Skip(1).Select(d => d - aDistances[0]));
            var bMoved = new[] {0}.Concat(aDistances.Skip(1).Select(d => d - aDistances[0]));

            var aString = Get(aDistances, length);
            var bString = Get(bDistances, length);

            Console.WriteLine((aString + aString).Contains(bString) ? "YES" : "NO");
        }
    }
}


// ac

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

namespace sar_cs
{
    static class Helpers
    {
        // Mono lacks this override of string.Join()
        public static string Join<T>(this IEnumerable<T> objs, string sep)
        {
            var sb = new StringBuilder();
            foreach (var s in objs) { if (sb.Length != 0) sb.Append(sep); sb.Append(s); }
            return sb.ToString();
        }

        public static string AsString(this double a, int digits)
        {
            return a.ToString("F" + digits, CultureInfo.InvariantCulture);
        }

        public static Stopwatch SW = Stopwatch.StartNew();
    }

    public class Program
    {
        #region Helpers

        public class Parser
        {
            const int BufSize = 8000;
            TextReader s;
            char[] buf = new char[BufSize];
            int bufPos;
            int bufDataSize;
            bool eos;   // eos read to buffer
            int lastChar = -2;
            int nextChar = -2;
            StringBuilder sb = new StringBuilder();

            void FillBuf()
            {
                if (eos) return;
                bufDataSize = s.Read(buf, 0, BufSize);
                if (bufDataSize == 0) eos = true;
                bufPos = 0;
            }

            int Read()
            {
                if (nextChar != -2)
                {
                    lastChar = nextChar;
                    nextChar = -2;
                }
                else
                {
                    if (bufPos == bufDataSize) FillBuf();
                    if (eos) lastChar = -1;
                    else lastChar = buf[bufPos++];
                }
                return lastChar;
            }

            void Back()
            {
                if (lastChar == -2) throw new Exception();  // no chars were ever read
                nextChar = lastChar;
            }

            public Parser()
            {
                s = Console.In;
            }

            public int ReadInt()
            {
                int res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-') { sign = 1; c = Read(); }
                int len = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new FormatException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new FormatException();
                Back();
                return checked(res * sign);
            }

            public long ReadLong()
            {
                long res = 0;
                int sign = -1;
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));
                if (c == '-')
                {
                    sign = 1;
                    c = Read();
                }
                int len = 0;

                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    if ((uint)(c -= 48) >= 10) throw new FormatException();
                    len++;
                    res = checked(res * 10 - c);
                    c = Read();
                }
                if (len == 0) throw new FormatException();
                Back();
                return checked(res * sign);
            }

            public int ReadLnInt()
            {
                int res = ReadInt(); ReadLine(); return res;
            }

            public long ReadLnLong()
            {
                long res = ReadLong(); ReadLine(); return res;
            }

            public double ReadDouble()
            {
                int c;
                do { c = Read(); } while (c >= 0 && char.IsWhiteSpace((char)c));

                int sign = 1;
                if (c == '-') { sign = -1; c = Read(); }

                sb.Length = 0;
                while (c >= 0 && !char.IsWhiteSpace((char)c))
                {
                    sb.Append((char)c); c = Read();
                }

                Back();
                var res = double.Parse(sb.ToString(), CultureInfo.InvariantCulture);
                return res * sign;
            }

            public string ReadLine()
            {
                int c = Read();
                sb.Length = 0;
                while (c != -1 && c != 13 && c != 10)
                {
                    sb.Append((char)c); c = Read();
                }
                if (c == 13) { c = Read(); if (c != 10) Back(); }
                return sb.ToString();
            }

            public bool SeekEOF
            {
                get
                {
                L0:
                    int c = Read();
                    if (c == -1) return true;
                    if (char.IsWhiteSpace((char)c)) goto L0;
                    Back();
                    return false;
                }
            }

            public int[] ReadIntArr(int n)
            {
                var a = new int[n]; for (int i = 0; i < n; i++) a[i] = ReadInt(); return a;
            }

            public long[] ReadLongArr(int n)
            {
                var a = new long[n]; for (int i = 0; i < n; i++) a[i] = ReadLong(); return a;
            }
        }

        static void pe() { Console.WriteLine("???"); Environment.Exit(0); }

        static void re() { Environment.Exit(55); }

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

        #endregion Helpers

        static StringBuilder sb = new StringBuilder();
        static Random rand = new Random(5);

        static int[] fcache;

        static int f(int n, int[] abc)
        {
            if (n < 0) return -1;
            if (n == 0) return 0;
            if (fcache[n] == -2)
            {
                int best = -1;
                foreach (var l in abc)
                {
                    int t = f(n - l, abc);
                    if (t >= 0) best = Math.Max(best, t);
                }
                fcache[n] = best < 0 ? -1 : best + 1;
            }
            return fcache[n];
        }

        static void Main(string[] args)
        {
            //sar_cs_structs.FenwickTree.Test(); return;
            //Console.SetIn(File.OpenText("_input"));
            var parser = new Parser();
            while (!parser.SeekEOF)
            {
                int n = parser.ReadInt();
                var abc = parser.ReadIntArr(3);

                fcache = new int[n+1];
                for (int i = 0; i < fcache.Length; i++) fcache[i] = -2;
                Console.WriteLine(f(n, abc));
            }
        }
    }
}


using System;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        int[] lines = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToArray();
        int n = lines[0];
        lines[0] = -1;
        Array.Sort(lines);

        int count = 1;

        if (n % lines[1] == 0)
        {
            Console.WriteLine(n/ lines[1]);
        }
        else
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < n; k++)
                    {
                        if (i * lines[1] + j * lines[2] + k * lines[3] == n)
                        {
                            if ((i + j + k) > count)
                            {
                                count = i + j + k;
                                continue;
                            }
                        }
                        else
                        {
                            if (i * lines[1] + j * lines[2] + k * lines[3] > n)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

namespace _218a
{
	class Program
	{
		static void Main(string[] args)
		{
			//Console.SetIn(File.OpenText("in.txt"));
			var d = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			var n = d[0];
			var k = d[1];
			var a = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

			var size = n / k;
			var change = 0;
			for (int i = 0; i < k; i++)
			{
				var s = i;
				var c1 = 0;
				var c2 = 0;
				while (s <= n - 1)
				{
					if (a[s] == 1)
					{
						c1++;
					}
					else
					{
						c2++;
					}

					s += k;
				}

				change += Math.Min(c1, c2);
			}

			Console.WriteLine(change);
		}
	}
}


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

namespace Codeforces_Round_218_2
{

    class TaskA
    {
        static void Main(string[] args)
        {
            int n, k;
            string s = Console.ReadLine();
            string[] str = s.Split(' ');
            n = int.Parse(str[0]);
            k = int.Parse(str[1]);

            int[] a = new int[n];
            s = Console.ReadLine();
            str = s.Split(' ');

            for (int i = 0; i < n; i++)
                a[i] = int.Parse(str[i]);

            int nk = n / k;
            int[] dif = new int[k];
            for (int i = 0; i < nk; i++)
            {
                for (int j = 0; j < k; j++)
                {
                    //Console.WriteLine("Comparing a[{0}] with 2. k={1}, i={2}, j={3}", k * i + j, k, i, j);
                    if (a[k * i + j] == 2)
                    {
                        dif[j]++;
                        //Console.WriteLine("dif[{0}]={1}", j, dif[j]);
                    }
                }
            }

            int changes = 0;
            for (int i = 0; i < k; i++)
            {
                if (dif[i] > nk / 2)
                    dif[i] = nk - dif[i];

                changes += dif[i];
            }

            Console.WriteLine(changes);
        }
    }
}


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

namespace olymp2
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int k = Convert.ToInt32(Console.ReadLine());
			int[] input = Console.ReadLine()
								 .Split(new char[] { ' ' })
								  .Select(x => Convert.ToInt32(x))
								  .ToArray();
			int HH = input[0];
			int MM = input[1];

			int btn = 0;
			while (HH % 10 != 7 && MM % 10 != 7)
			{
				if (MM - k < 0)
				{
					MM = 60 + MM - k;
					HH--;
				}
				else
				{
					MM -= k;
				}
				if (HH < 0)
				{
					HH = 23;
				}

				btn++;
			}

			Console.WriteLine(btn);

		}
	}
}


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

namespace jamieandalarmsnooze
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = Int32.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int hh = Int32.Parse(input[0]);
            int mm = Int32.Parse(input[1]);
            if (hh == 07 || hh == 17 || mm == 07 || mm == 17 || mm == 27 || mm == 37 || mm == 47 || mm == 57)
                Console.WriteLine("0");
            else
            {
                int time = hh * 60 + mm;
                for(int i=0; ;i++)
                {
                    int h = time / 60;
                    int m = time % 60;
                    time = (time - x + 1440) % 1440;
                    if(h/10==7||h%10==7||m/10==7||m%10==7)
                    {
                        Console.WriteLine(i);
                        break;
                    }

                }

            }
        }
    }
}


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

namespace A_DieRoll
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] cases = Console.ReadLine().Split(' ');
            int max = Math.Max(int.Parse(cases[0]), int.Parse(cases[1]));
            int wins = 0;
            while (max <= 6)
            {
                max++;
                wins++;
            }
            switch (wins)
            {
                case 1:
                    Console.WriteLine("1/6");
                    break;
                case 2:
                    Console.WriteLine("1/3");
                    break;
                case 3:
                    Console.WriteLine("1/2");
                    break;
                case 4:
                    Console.WriteLine("2/3");
                    break;
                case 5:
                    Console.WriteLine("5/6");
                    break;
                case 6:
                    Console.WriteLine("1/1");
                    break;
            }
            Console.ReadLine();
        }
    }
}


using System;
namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] attemps = GetInts();

            SolveProblem(attemps);
            Console.ReadLine();
        }

        static void SolveProblem(int [] attemps)
        {
            int num = (6 - ((Math.Max(attemps [0], attemps [1]))-1));
            int denum = 6;

            if (num == 6)
            {
                Console.WriteLine("1/1");
            }else
            {
                int df = gcd(num, denum);
                Console.WriteLine("{0}/{1}", num /= df, denum /= df);
            }
        }

        static int gcd (int a, int b)
        {
            if (a == 0)
            {
                return b;
            }else if (b == 0)
            {
                return a;
            }

            return a > b ? gcd (a & b, b) : gcd (a , b % a);
        }
        static int[] GetInts()
        {
            string[] s = (Console.ReadLine()).Split(' ');
            int[] integers = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                integers[i] = int.Parse(s[i]);
            }
            return integers;
        }

    }
}


using System;
namespace _784E
{
    class Program
    {
        static void Main(string[] args)
        {
            bool a1 = Console.ReadLine() == "1";
            bool a2 = Console.ReadLine() == "1";
            bool a3 = Console.ReadLine() == "1";
            bool a4 = Console.ReadLine() == "1";
            bool b1 = a1 ^ a2;
            bool b2 = a3 | a4;
            bool b3 = a2 & a3;
            bool b4 = a1 ^ a4;
            bool c1 = b1 & b2;
            bool c2 = b3 | b4;
            bool result = c1 ^ c2;
            Console.WriteLine(result ? "1" : "0");
        }
    }
}


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

namespace ConsoleApplication1
{
    class vccup1
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader(@"D:\Sergey\Code\1.txt"));

            string[] strParams = Console.ReadLine().Split(new char[] { ' ' });
            int n = int.Parse(strParams[0]);
            int c = int.Parse(strParams[1]);

            //var a = new List<int>();
            strParams = Console.ReadLine().Split(new char[] { ' ' });
            string[] strParams2 = Console.ReadLine().Split(new char[] { ' ' });

            int[] p = new int[n];
            int[] t = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = int.Parse(strParams[i]);
                t[i] = int.Parse(strParams2[i]);
            }

            int r1 = 0, r2 = 0;
            long s1 = 0, s2 = 0;
            long r = 0;
            for (int i = 0; i < n; i++)
            {
                r1 += t[i];
                s1 += Math.Max(0, p[i] - c * r1);

                r2 += t[n - 1 - i];
                s2 += Math.Max(0, p[n - 1 - i] - c * r2);
            }

            if (s1 > s2)
                Console.WriteLine("Limak");
            else if (s1 < s2)
                Console.WriteLine("Radewoosh");
            else
                Console.WriteLine("Tie");
        }//main
    }
}


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

namespace algorithms_700_01
{
    class Program
    {
        static void Main()
        {
            var array = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToArray();
            var minuteCost = array[1];
            var scores = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToArray();
            var times = Console.ReadLine().Split(new char[] { ' ' }).Select(x => int.Parse(x)).ToArray();
            int limakPoints = 0, limakTime = 0;
            int radewooshPoints = 0, radewooshTime = 0;
            for (int i = 0; i < scores.Length; i++)
            {
                limakTime += times[i];
                limakPoints += Math.Max(0, scores[i] - minuteCost * limakTime);
                radewooshTime += times[scores.Length - i - 1];
                radewooshPoints += Math.Max(0, scores[scores.Length - i - 1] - minuteCost * radewooshTime);
            }
            if (limakPoints > radewooshPoints)
                Console.WriteLine("Limak");
            else if (limakPoints < radewooshPoints)
                Console.WriteLine("Radewoosh");
            else
                Console.WriteLine("Tie");
        }
    }
}


using System;

class Program
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split();

        int result = int.Parse(input[0]);
        int time = int.Parse(input[1]);
        int cost1 = int.Parse(input[2]);
        int cost2 = int.Parse(input[3]);
        int lose1 = int.Parse(input[4]);
        int lose2 = int.Parse(input[5]);

        bool answer = (result == 0);

        for (int time1 = 0; time1 < time && !answer; time1++)
        {
            int points1 = cost1 - time1 * lose1;
            if (points1 == result)
                answer = true;

            for (int time2 = 0; time2 < time && !answer; time2++)
            {
                int points2 = cost2 - time2 * lose2;
                if (points2 == result || points1 + points2 == result)
                    answer = true;
            }
        }

        if (answer)
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }
}


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

namespace UpSolve
{
    class Program
    {
#if DEBUG
        static TextReader In = new StreamReader("../../input.txt");
        static TextWriter Out = new StreamWriter("../../output.txt");
#else
        static TextReader In = Console.In;
        static TextWriter Out = Console.Out;
#endif

        static void Main(string[] args) {
            int x, t, a, b, da, db;
            string[] tokens = In.ReadLine().Split();
            x = int.Parse(tokens[0]);
            t = int.Parse(tokens[1]);
            a = int.Parse(tokens[2]);
            b = int.Parse(tokens[3]);
            da = int.Parse(tokens[4]);
            db = int.Parse(tokens[5]);

            for (int i = 0; i <= t; i++)
            {
                for (int j = 0; j <= t; j++)
                {
                    int q = i == t ? 0 : a - da*i;
                    int w = j == t ? 0 : b - db*j;

                    if (q + w == x)
                    {
                        Out.WriteLine("YES");
                        Out.Close();
                        return;
                    }
                }
            }

            Out.WriteLine("NO");
            Out.Close();
        }
    }
}


using System;

class Program
{
    static void Main()
    {
        var row = 1;
        var result = 0;
        while (true)
        {
            var line = Console.ReadLine().Replace(" ", "");
            var col = line.IndexOf("1");
            if (col >= 0)
            {
                result = Math.Abs(3 - row) + Math.Abs(3 - (col + 1));
                break;
            }
            row++;
        }
        Console.WriteLine(result);
    }
}


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

namespace ConsoleApp9
{
    class Program
    {
        static void Main(string[] args)
        {
            var res = 0;
            var liste = new List<int>();

            for (var i = 1; i <= 5; i++)
            {
                var array = Console.ReadLine().Trim().Split(' ');
                liste.Clear();

                foreach (var q in array) { liste.Add(int.Parse(q)); }

                if (liste.Contains(1))
                {
                    res += Math.Abs(i - 3);
                    res += Math.Abs(2 - liste.IndexOf(1));
                }
            }

            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}


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

namespace Learning
{
    class Program
    {
        static bool s_multiTest = false;
        static void Main(string[] args)
        {
            var o = Console.Out;
            var nTest = 1;
            if (s_multiTest)
            {
                nTest = NextInt();
            }

            for (int testId = 1; testId <= nTest; testId++)
            {
                Solve(testId, o);
            }
            Console.ReadLine();
        }

        private static void Solve(int testId, TextWriter o)
        {
            var p = new int[4];
            for (var i = 0; i < 4; ++i)
                p[i] = NextInt();
            var from = NextInt();
            var to = NextInt();
            var ans = 0;
            for (var cur = from; cur <= to; cur++)
            {
                var can = 0;
                int val = cur;
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (j == i)
                            continue;
                        for (int k = 0; k < 4; k++)
                        {
                            if (k == i || k == j)
                                continue;

                            for (int l = 0; l < 4; l++)
                            {
                                if (l == i || l == j || l == k)
                                    continue;
                                val = val % p[i] % p[j] % p[k] % p[l];
                                if (val == cur)
                                    can++;
                            }
                        }
                    }
                }
                if (can >= 7)
                    ans++;
            }
            o.WriteLine(ans);
        }

        static int s_index = 0;
        static string[] s_tokens;
        private static string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Length)
            {
                s_tokens = Console.ReadLine().Split(' ').ToArray();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        private static int NextInt()
        {
            return Int32.Parse(Next());
        }

        private static long NextLong()
        {
            return Int64.Parse(Next());
        }
    }
}


using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Codeforces
{
	internal class Template
	{
		private void Solve()
		{
		    var n = cin.NextInt();
		    if (n%2 == 1 || n < 6)
		    {
		        Console.WriteLine(0);
		        return;
		    }
		    n /= 2;
		    n = (n- 1) / 2;
            Console.WriteLine(n);
		}

		private static readonly Scanner cin = new Scanner();

		private static void Main()
		{
#if DEBUG
			var inputText = File.ReadAllText(@"..\..\input.txt");
			var testCases = inputText.Split(new[] { "input" }, StringSplitOptions.RemoveEmptyEntries);
			var consoleOut = Console.Out;
			for (var i = 0; i < testCases.Length; i++)
			{
				var parts = testCases[i].Split(new[] { "output" }, StringSplitOptions.RemoveEmptyEntries);
				Console.SetIn(new StringReader(parts[0].Trim()));
				var stringWriter = new StringWriter();
				Console.SetOut(stringWriter);
				var sw = Stopwatch.StartNew();
				new Template().Solve();
				sw.Stop();
				var output = stringWriter.ToString();

				Console.SetOut(consoleOut);
				var color = ConsoleColor.Green;
				var status = "Passed";
				if (parts[1].Trim() != output.Trim())
				{
					color = ConsoleColor.Red;
					status = "Failed";
				}
				Console.ForegroundColor = color;
				Console.WriteLine("Test {0} {1} in {2}ms", i + 1, status, sw.ElapsedMilliseconds);
			}
			Console.ReadLine();
			Console.ReadKey();
#else
			new Template().Solve();
			Console.ReadLine();
#endif
		}
	}

	internal class Scanner
	{
		private string[] s = new string[0];
		private int i;
		private readonly char[] cs = { ' ' };

		public string NextString()
		{
			if (i < s.Length) return s[i++];
			var line = Console.ReadLine() ?? string.Empty;
			s = line.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 1;
			return s.First();
		}

		public double NextDouble()
		{
			return double.Parse(NextString());
		}

		public int NextInt()
		{
			return int.Parse(NextString());
		}

		public long NextLong()
		{
			return long.Parse(NextString());
		}
	}
}


using System;
using System.Collections.Generic;
namespace test1cs
{
    class Program
    {
        static void Main(string[] args)
        {
            int sum = 0;
            int x = int.Parse(Console.ReadLine());
            int b = x / 2;
            for (int i = 1;     i<b; i++)
            {
                int s = b - i;
                if((s+i)*2==x)
                {
                    sum++;
                }
            }
            Console.WriteLine(sum/2);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _1A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int n = t.Length;
            int ans = 1;
            for (int i = 0; i < n; i++)
            {
                if (t[i] == s[ans - 1])
                    ans++;
            }
                Console.WriteLine(ans);

           // Console.ReadKey();
        }

    }
}


using System;
namespace ConsoleApplication1
{
    class Program
    {
        public static void Main(string[] args)
        {

            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int pos=0;
            for (int i = 0; i < t.Length; i++)
            {
                if (s[pos] == t[i])
                {
                    pos++;
                }
            }
            Console.WriteLine(pos + 1);
        }
    }
}


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

namespace Contest.A
{
    class Program
    {
        /////////////////////

        public static T Read<T>()
        {
            return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
        }

        public static List<T> ReadList<T>(char[] delimiters = null)
        {
            var line = Read<string>();
            var split = line.Split(delimiters ?? new[] { ' ' });
            var list = split.Select(item => (T)Convert.ChangeType(item, typeof(T))).ToList();
            return list;
        }

        public static List<KeyValuePair<int, T>> ReadIndexedList<T>(char[] delimiters = null)
        {
            var line = Read<string>();
            var split = line.Split(delimiters ?? new[] { ' ' });
            var list = split.Select((item, index) => new KeyValuePair<int, T>(index + 1, (T)Convert.ChangeType(item, typeof(T)))).ToList();
            return list;
        }

        public static void ReadFromFile()
        {
            Console.SetIn(new StreamReader(@"..\..\input.txt"));
        }

        ///////////////////////////////////

        static void Main(string[] args)
        {
            try
            {
                var list = ReadList<int>();
                int r = list[0];
                int g = list[1];
                int b = list[2];

                int rr = (int) Math.Ceiling(r/2d);
                int gg = (int) Math.Ceiling(g / 2d);
                int bb = (int) Math.Ceiling(b / 2d);

                int res = 30 + Max(0 + (rr - 1)*3 , 1 + (gg - 1)*3 , 2 + (bb - 1)*3);
                Console.WriteLine(res);
            }
            catch
            {
                Console.Write("ERROR");
            }
        }

        private static int Max(int i, int i1, int i2)
        {
            return Math.Max(Math.Max(i, i1), i2);
        }
    }
}


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

class ProblemA
{
    static void Main(string[] args)
    {
        string[] tokens = Console.ReadLine().Split(' ');
        int r = int.Parse(tokens[0]), g = int.Parse(tokens[1]), b = int.Parse(tokens[2]);
        Console.WriteLine(30 + Math.Max(((r + 1) / 2 - 1) * 3, Math.Max(1 + ((g + 1) / 2 - 1) * 3, 2 + ((b + 1) / 2 - 1) * 3)));
    }
}


using System;
using Math = System.Math;
using Dec = System.Decimal;
using System.Globalization;
using System.Linq;

namespace taskA
{
	class newDecimal {
	private
			Int64 Z, F, kol;
	public newDecimal(decimal t, Int64 Kol) {
			kol = Kol;
			Z = Dec.ToInt64 (t);
			Int64 p = 1;
			for (int i = 0; i < kol; i ++)
				p *= 10L;
			F = Dec.ToInt64 ((t - Z) * p);
		}
		public void print () {
			Console.Write ("{0}.", Z);
			int sz = F.ToString ().Length;
			for (int i = 0; i < kol - sz; i ++)
				Console.Write (0);
			Console.Write (F);
		}
	}

	class MainClass
	{
		public static void Main(string[] args) {
			int n = int.Parse (Console.ReadLine());
			long ans = ((1L << n) - 1L) << 1;
			Console.WriteLine(ans);
		}
	}
}


using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine()); ulong ans = 0;
            for(int i = 1; i<= n; i++)
                ans+=(ulong)Math.Pow(2, i);
            Console.Write(ans);
        }
    }
}


using System;
using System.Linq;

namespace problemsets_for_codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            //watermelon
            //byte w = byte.Parse(Console.ReadLine());
            //if (w%2==0&&w!=2)
            //    Console.WriteLine("YES");
            //else
            //    Console.WriteLine("NO");

            //byte n = byte.Parse(Console.ReadLine()); string[] words = new string[n];
            //for (byte i = 0; i<n; i++)
            //{
            //    words[i] = Console.ReadLine();
            //}
            //foreach (string word in words)
            //{
            //    if (word.Length > 10)
            //    {
            //        Console.WriteLine("{0}{1}{2}", word[0], word.Length - 2, word[word.Length - 1]);
            //    }
            //    else
            //        Console.WriteLine(word);
            //}

            //string word = Console.ReadLine().ToLower();char[] wordArray = new char[word.Length];byte count = 0;
            //foreach (char ch in word) {
            //    if(ch != 'a' && ch != 'o' && ch != 'y' && ch != 'e'&& ch != 'u' && ch != 'i') {
            //        wordArray[count] = ch;
            //        count++;
            //    }
            //}
            //for (int x =0; x < count; x++)
            //{
            //    Console.Write(".{0}", wordArray[x]);
            //}

            //string s1 = Console.ReadLine().ToLower(), s2 = Console.ReadLine().ToLower();
            ////int x1 = 0, x2 = 0;
            ////foreach (char c in s1)
            ////    x1 += Convert.ToInt32(c);
            ////foreach (char c in s2)
            ////    x2 += Convert.ToInt32(c);
            ////if (x1 > x2)
            ////    Console.WriteLine(1);
            ////else if (x1 == x2)
            ////    Console.WriteLine(0);
            ////else
            ////    Console.WriteLine(-1);
            //for (int count = 0; count < s1.Length; count++)
            //{
            //    if (s1[count] > s2[count])
            //    {
            //        Console.WriteLine(1);
            //        break;
            //    }
            //    else if(s2[count] > s1[count])
            //    {
            //        Console.WriteLine(-1);
            //        break;
            //    }
            //}
            //if (s1 == s2)
            //    Console.WriteLine(0);
            //}

            //string sum = Console.ReadLine(); int numberCount = 0;
            ////count numbers
            //for (int x = 0; x < sum.Length; x++)
            //{
            //    //if (x < sum.Length - 1 && sum[x + 1] != '+' && sum[x] != '+')
            //    //{
            //    //    numberCount++;
            //    //    x++;
            //    //}
            //    if(sum[x] != '+')
            //        numberCount++;
            //}

            ////get numbers
            //int[] numbers = new int[numberCount];
            //numberCount = 0;
            //for (int x = 0; x < sum.Length; x++)
            //{
            //    //if (x < sum.Length - 1 && sum[x + 1] != '+' && sum[x] != '+')
            //    //{
            //    //    numbers[numberCount] = int.Parse(sum[x].ToString() + sum[x + 1].ToString());
            //    //    numberCount++;
            //    //    x++;
            //    //}
            //    if(sum[x] != '+')
            //    {
            //        numbers[numberCount] = int.Parse(sum[x].ToString());
            //        numberCount++;
            //    }
            //}

            ////sort numbers
            //Array.Sort(numbers);
            ////print
            //Console.Write(numbers[0]);
            //for(int x = 1; x< numbers.Length; x++)
            //{
            //    Console.Write("+" + numbers[x]);
            //}

            ////read input
            //Byte n = Byte.Parse(Console.ReadLine());
            //UInt32[] a = new UInt32[n];UInt32 sum1 = 0, sum2 = 0;
            //string x = Console.ReadLine();
            //for (int i = 0; i < n; i++) {
            //    a[i] = Convert.ToUInt32(x.Split(' ')[i]);
            //    sum1 += a[i];
            //}

            ////sort
            //Array.Sort(a);

            //for(int i = 0; i < n; i++)
            //{
            //    sum1 -= a[i];
            //    sum2 += a[i];
            //    if (sum2 > sum1)
            //    {
            //        i++;
            //        Console.WriteLine(i);
            //        break;

            //string s = Console.ReadLine().ToLower();
            //int letter = 1;
            //for(int i = 0; i < s.Length; i++)
            //{
            //    switch (letter)
            //    {
            //        case 1:
            //            if (s[i] == 'h')
            //                letter++;
            //            break;
            //        case 2:
            //            if (s[i] == 'e')
            //                letter++;
            //            else if (s[i] == 'h')
            //                break;
            //            else
            //                letter = 0;
            //            break;
            //        case 3:
            //            if (s[i] == 'l' && s[i + 1] != 'l' && i < s.Length - 1)
            //                letter++;
            //            else if (s[i] == 'e' || s[i] == 'l')
            //                break;
            //            else
            //                letter = 0;
            //            break;
            //        case 4:
            //            if (s[i] == 'o')
            //            {
            //                Console.WriteLine("YES");
            //                i = s.Length;
            //            }
            //            else
            //                letter = 0;
            //            break;
            //        default:
            //            Console.WriteLine("NO");
            //            i = s.Length;
            //            break;
            //    }
            //}

            char[] s = Console.ReadLine().ToLower().ToCharArray(); string hello = "hello";
            for(int sInd = 0,helloIndex = 0; sInd < s.Length; sInd++)
            {
                if (helloIndex < 5 && s[sInd] == hello[helloIndex])
                    helloIndex++;
                else
                    s[sInd] = '0';
            }
            string s2 = "";
            for(int sInd = 0; sInd < s.Length; sInd++)
            {
                if (s[sInd] != '0')
                    s2 += Convert.ToString(s[sInd]);
            }
            Console.WriteLine(hello == s2 ? "YES" : "NO");

        }
    }
}


using System;
public class Program
{
    public static void Main()
    {
        var input = Console.ReadLine();
        var expected = "hello";

        int lastIndex = -1;

        for(int i = 0; i < expected.Length; ++i)
        {
            lastIndex = input.IndexOf(expected[i], ++lastIndex);
            if(lastIndex == -1) break;
        }

		if(lastIndex == -1)
		{
			Console.WriteLine("NO");
		}
		else
		{
        	Console.WriteLine("YES");
		}
    }
}


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

namespace CodeForces
{
	class Program
	{
		static void Main(string[] args)
		{
			read();
			var vals = readMany<int>().ToList();

			int current = 0;
			foreach (int min in vals)
			{
				if (min - current > 15)
				{
					Console.WriteLine(current + 15);
					return;
				}
				else
				{
					current = min;
				}
			}
			Console.WriteLine(Math.Min(current + 15, 90));
		}

		private delegate void o(string format, params object[] args);
		private static o Output;

		private static T read<T>()
		{
			return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
		}

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

		private static T[] readMany<T>()
		{
			return readMany<T>(' ');
		}

		private static _[] readMany<_>(params char[] ___)
		{
			return read().Split(___).Select(__ => (_)Convert.ChangeType(__, typeof(_))).ToArray();
		}

		private static string[] readMany()
		{
			return readMany<string>();
		}

		private static T[][] readField<T>(int height, Func<char, T> map)
		{
			T[][] res = new T[height][];
			for (int _ = 0; _ < height; _++)
			{
				res[_] = read().Select(c => map(c)).ToArray();
			}
			return res;
		}

		private static char[][] readField(int height)
		{
			return readField(height, c => c);
		}

		private static T[][] readField<T>(int height, Dictionary<char, T> dic)
		{
			return readField(height, c => dic[c]);
		}

		static Func<T1, TResult> DP<T1, TResult>(Func<T1, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1>, TResult>();
			return (t1) =>
			{
				var key = Tuple.Create(t1);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1));
				return cache[key];
			};
		}

		static Func<T1, T2, TResult> DP<T1, T2, TResult>(Func<T1, T2, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2>, TResult>();
			return (t1, t2) =>
			{
				var key = Tuple.Create(t1, t2);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2));
				return cache[key];
			};
		}

		static Func<T1, T2, T3, TResult> DP<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3>, TResult>();
			return (t1, t2, t3) =>
			{
				var key = Tuple.Create(t1, t2, t3);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3));
				return cache[key];
			};
		}

		static Func<T1, T2, T3, T4, TResult> DP<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3, T4>, TResult>();
			return (t1, t2, t3, t4) =>
			{
				var key = Tuple.Create(t1, t2, t3, t4);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, t4));
				return cache[key];
			};
		}

		static IEnumerable<long> range(long first, long last, long step = 1)
		{
			for (long i = first; i <= last; i += step)
			{
				yield return i;
			}
		}

		static IEnumerable<int> range(int first, int last, int step = 1)
		{
			for (int i = first; i <= last; i += step)
			{
				yield return i;
			}
		}
	}

	public static class ExtensionMethods
	{
		public static IEnumerable<TOut> Cartesian<T1, T2, TOut>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TOut> collector)
		{
			return first.SelectMany(f => second.Select(s => collector(f, s)));
		}

		public static IEnumerable<Tuple<T1, T2>> Cartesian<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			return first.Cartesian(second, Tuple.Create);
		}

		public static IEnumerable<Tuple<T1, T2, T3>> Cartesian<T1, T2, T3>(this IEnumerable<Tuple<T1, T2>> first, IEnumerable<T3> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4>> Cartesian<T1, T2, T3, T4>(this IEnumerable<Tuple<T1, T2, T3>> first, IEnumerable<T4> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4, T5>> Cartesian<T1, T2, T3, T4, T5>(this IEnumerable<Tuple<T1, T2, T3, T4>> first, IEnumerable<T5> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));
		}

		public static IEnumerable<IEnumerable<T>> Pow<T>(this IEnumerable<T> it, int num)
		{
			IEnumerable<IEnumerable<T>> res = it.Select(x => new[] { x });
			for (int i = 0; i < num - 1; i++)
			{
				res = res.Cartesian(it, (sofar, n) => sofar.Concat(new[] { n }));
			}
			return res;
		}

		public static IEnumerable<T> Demask<T>(this IEnumerable<Tuple<T, bool>> inp)
		{
			foreach (var pair in inp)
			{
				if (pair.Item2)
				{
					yield return pair.Item1;
				}
			}
		}

		public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> it)
		{
			foreach (var conf in new[] { true, false }.Pow(it.Count()))
			{
				yield return it.Zip(conf, Tuple.Create).Demask();
			}
		}

		private static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		private static IEnumerable<T> ExceptSingle<T>(this IEnumerable<T> first, T it, IEqualityComparer<T> comp = null)
		{
			comp = comp ?? EqualityComparer<T>.Default;
			bool seen = false;
			foreach (T a in first)
			{
				if (seen)
				{
					yield return a;
				}
				else if (comp.Equals(a, it))
				{
					seen = true;
				}
				else
				{
					yield return a;
				}
			}
		}

		public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> it)
		{
			if (it.Count() < 2)
			{
				yield return it;
				yield break;
			}

			foreach (T first in it)
			{
				foreach (IEnumerable<T> part in Permutations(it.ExceptSingle(first)))
				{
					yield return single(first).Concat(part);
				}
			}
		}
	}
}


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

namespace Codeforces673A
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();
            int n = Convert.ToInt32(inp);
            string inp2 = Console.ReadLine() + " 90";
            string[] str = inp2.Split(' ');
            int outp = 90;

            int prev_min = 0;
            foreach (string s in str)
            {
                int minute = Convert.ToInt32(s);
                if (minute - prev_min > 15)
                {
                    outp = prev_min + 15;
                }
                else
                {
                    prev_min = minute;
                }
            }
            outp = outp > 90 ? 90 : outp;

            Console.WriteLine(outp);
            //inp = Console.ReadLine();
        }
    }
}


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

namespace ConsoleApp
{
    class Program
    {
        static void Main()
        {
            var n = Reader.ReadIntArgs();
            var s = Console.ReadLine();

            int cnt = 0;
            int ans = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'x')
                {
                    cnt++;
                }
                else
                {
                    ans += cnt > 2 ? cnt - 2 : 0;
                    cnt = 0;
                }
            }

            ans += cnt > 2 ? cnt - 2 : 0;

            Console.WriteLine(ans);
        }

        static bool IsPol(string s)
        {
            int l = 0;
            int r = s.Length - 1;

            while (l < r)
            {
                if (s[l] != s[r])
                    return false;

                l++;
                r--;
            }

            return true;
        }
    }

    static class Reader
    {
        public static List<int> ReadIntArgs()
        {
            return ReadArgs(int.Parse);
        }

        public static List<long> ReadLongArgs()
        {
            return ReadArgs(long.Parse);
        }

        private static List<T> ReadArgs<T>(Func<string, T> parser)
        {
            return Console.ReadLine().Split().Select(parser).ToList();
        }

        public static int ReadIntValue()
        {
            return ReadValue(int.Parse);
        }

        public static long ReadLongValue()
        {
            return ReadValue(long.Parse);
        }

        private static T ReadValue<T>(Func<string, T> parser)
        {
            return parser(Console.ReadLine());
        }
    }
}


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

namespace A.Anton_and_Polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int cont = 0;
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                if(s[i] == 'x')
                {
                    cont++;
                }
                else
                {
                    if (cont <= 2)
                    {
                        cont = 0;
                        continue;
                    }
                    cont -= 2;
                    sum +=cont;
                    cont = 0;
                }

            }
            if(cont > 2)
            {
                cont -= 2;
                sum += cont;
                cont = 0;
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }
}


using System;

class Program
{
	static void Main(string[] args)
	{
	    var ss = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(ss[0]);
        var m = int.Parse(ss[1]);
        var GL = true;
        var HF = false;
		string s = Console.ReadLine();
		for (int i=0; i+m+1<=n; i++)
		{
		    var ok = false;
		    for (int j=0; j<=m; j++)
	            if (s[i+j] != 'N')
		            ok = true;
			if (!ok)
			    GL = false;
		}
		for (int i=0; i+m<=n; i++)
		{
		    var ok = true;
		    for (int j=0; j<m; j++)
		        if (s[i+j] == 'Y')
		            ok = false;
		    if (i != 0 && s[i-1] == 'N')
		        ok = false;
		    if (i+m != n && s[i+m] == 'N')
		        ok = false;
		    if (ok)
		        HF = true;
		}
		if (GL && HF)
		    Console.Write("YES\n");
		else
		    Console.Write("NO\n");
	}
}


using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var nn = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var k = nn[1];
        var n = nn[0];
        string str;
        str = Console.ReadLine();
        var cur1 = 0;
        var cur2 = 0;
        var mx1 = 0;
        var mx2 = 0;
        for (var i = 0; i < n; i++) {
            if (str[i] == 'Y') {
                cur1 = 0;
                cur2 = 0;
            }
            else if (str[i] == 'N') {
                cur1++;
                cur2++;
            }
            else {
                cur1 = 0;
                cur2++;
            }
            if (cur1 > mx1) {
                mx1 = cur1;
            }
            if (cur2 > mx2) {
                mx2 = cur2;
            }
        }
        cur2 = 0;
        mx2 = 1;
        if (mx1 > k) {
            mx2 = 0;
        }
        for (var i = 0; i <= n - k; i++) {
            cur1 = 1;
            if ((i == 0 || (i > 0 && str[i - 1] != 'N')) && (i + k == n || (i + k < n && str[i + k] != 'N'))) {
                for (var j = 0; j < k; j++) {
                    if (str[i + j] == 'Y') {
                        cur1 = 0;
                    }
                }
                if (cur1 == 1) {
                    cur2 = 1;
                }
            }
        }
        if (mx2 == 0) {
            Console.WriteLine("NO");
        }
        else if (cur2 == 1) {
            Console.WriteLine("YES");
        }
        else {
            Console.WriteLine("NO");
        }
    }

}


using System;
namespace _893B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long result = 0;
            for (int j = 1; j < 25; j++)
            {
                long num = ((1L << j) - 1L) * (1L << (j - 1));
                if (num <= n && n % num == 0 && num > result)
                    result = num;
            }
            Console.WriteLine(result);
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _893B
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(Enumerable.Range(1, n).Where(d => n % d == 0 && IsBeautiful(d)).Max());
        }

        private static bool IsBeautiful(int n)
        {
            string binary = Convert.ToString(n, 2);
            int k = binary.Length / 2;
            return binary.Take(k + 1).All(c => c == '1') && binary.Reverse().Take(k).All(c => c == '0');
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] mouth = new int[] { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

            int total = 1;

            string line = Console.ReadLine();

            int m = int.Parse(line.Split(' ')[0]),
                d = int.Parse(line.Split(' ')[1]);

            d = mouth[m] - (8 - d);

            //Console.WriteLine("{0} {1}", d, (decimal)d/7);
            total += (int)Math.Ceiling((decimal)d / 7);

            Console.WriteLine(total);

        }
    }
}


using System;

namespace Number760A {
    class Program {
        static void Main(string[] args) {
            var mas = Console.ReadLine().Split(' ');
            Int32 numberMonth = Int32.Parse(mas[0]);
            Int32 numberWeekDays = Int32.Parse(mas[1]);
            Int32 days = GetCountDays(numberMonth) - 8 + numberWeekDays;
            Int32 mod = days % 7 == 0 ? 0 : 1;
            Console.WriteLine((Int32)(days / 7.0) + mod + 1);
        }

        static Int32 GetCountDays(Int32 m) {
            if(m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
                return 31;
            if(m == 4 || m == 6 || m == 9 || m == 11)
                return 30;
            return 28;
        }
    }
}


/*
Author : Shivakkumar K R
File name : 313_Div2_ProbB.cs
*/
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;
public class _313_Div2_ProbB {
	static int max(int a, int b)
	{
		return Math.Max(a, b);
	}
	static void swap<T>(ref T a, ref T b) {
		T c = a;
		a = b;
		b = c;
	}
	static void Main(string [] args) {
		//Console.SetIn(new StreamReader(File.OpenRead("C://Users//Shiva//Desktop//313_Div2_ProbB.txt")));
		var input = Console.ReadLine().Split(new char[] {});
		int a = int.Parse(input[0]), b = int.Parse(input[1]);
		input = Console.ReadLine().Split(new char[] {});
		int c = int.Parse(input[0]), d = int.Parse(input[1]);
		input = Console.ReadLine().Split(new char[] {});
		int e = int.Parse(input[0]), f = int.Parse(input[1]);

		for (int i = 0; i < 4; i++) {
			if ((a >= (c + e) && b >= d && b >= f) || (b >= (d + f) && a >= c && a >= e)) {
				Console.WriteLine("YES"); return;
			}
			if (i % 2 == 0) swap(ref c, ref d);
			swap(ref e, ref f);
		}

		Console.WriteLine("NO");
	}
}


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

namespace _560B_Gerald_is_into_Art
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] board = Console.ReadLine().Split();
            string[] painting1 = Console.ReadLine().Split();
            string[] painting2 = Console.ReadLine().Split();

            int a1 = int.Parse(board[0]);
            int b1 = int.Parse(board[1]);

            int a2 = int.Parse(painting1[0]);
            int b2 = int.Parse(painting1[1]);

            int a3 = int.Parse(painting2[0]);
            int b3 = int.Parse(painting2[1]);

            bool fits = false;

            // naast elkaar op zijde a1

            if (a1 >= a2 + a3 && !fits)
            {
                if (b1 >= Math.Max(b2, b3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            if (a1 >= a2 + b3 && !fits)
            {
                if (b1 >= Math.Max(b2, a3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            if (a1 >= b2 + a3 && !fits)
            {
                if (b1 >= Math.Max(a2, b3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            if (a1 >= b2 + b3 && !fits)
            {
                if (b1 >= Math.Max(a2, a3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            // naast elkaar op zijde b1

            if (b1 >= a2 + a3 && !fits)
            {
                if (a1 >= Math.Max(b2, b3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            if (b1 >= a2 + b3 && !fits)
            {
                if (a1 >= Math.Max(b2, a3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            if (b1 >= b2 + a3 && !fits)
            {
                if (a1 >= Math.Max(a2, b3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            if (b1 >= b2 + b3 && !fits)
            {
                if (a1 >= Math.Max(a2, a3))
                {
                    Console.WriteLine("YES");
                    fits = true;
                }
            }

            // If nothing fits

            if (!fits)
                Console.WriteLine("NO");
        }
    }
}


using System;

namespace myApp {
    class Program {
        static void Main (string[] args) {
            int[] a = new int[5];
            for(int i = 0; i < 5; i++)
                a[i] = int.Parse(Console.ReadLine());
            bool[] harmed = new bool[a[4]+1];
            int rs = 0;
            for(int i = 0; i < 4; i++){
                if(a[i] == 1){
                    rs = a[4]; break;
                    }
                for(int j = 1; j * a[i] <= a[4]; j++)
                    if(!harmed[j*a[i]]) {
                        harmed[j*a[i]] = true;
                        rs++;
                    }
            }
            Console.WriteLine(rs);
        }
    }
}


using System;
using System.Collections.Generic;
namespace problems
{
    internal class _148A
    {
        private static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            var l = int.Parse(Console.ReadLine());
            var m = int.Parse(Console.ReadLine());
            var n = int.Parse(Console.ReadLine());
            var d = int.Parse(Console.ReadLine());
            int result=0;
            Calc(new[] { k, l, m, n }, 0, new List<int>(),d, ref result);

            //int result = d / k + d / l + d / m + d / n
            //             - d / lcm(k, m) - d / lcm(k, l) - d / lcm(k, n) - d / lcm(l, m) - d / lcm(n, m) - d / lcm(l, n)
            //             + d / lcm(k, l, n) + d / lcm(k,l, m) + d / lcm(m, l, n) + d / lcm(k, m, n)
            //    - d / lcm(k, l, m, n);
            Console.WriteLine(result);
        }

        private static void Calc(int[] array, int at, List<int> subset,int d, ref int result)
        {
            if (at == array.Length && subset.Count > 0)
            {
                result += d * ((subset.Count % 2 == 0) ? -1 : 1) / lcm(subset);
                return;
            }
            else if(at<array.Length)
            {
                Calc(array, at + 1, subset, d, ref result);
                subset.Add(array[at]);
                Calc(array, at + 1, subset, d, ref result);
                subset.RemoveAt(subset.Count - 1);
            }
        }

        private static int gcd(int a, int b)
        {
            while (b != 0)
            {
                var t = b;
                b = a % b;
                a = t;
            }
            return a;
        }

        private static int lcm(int a, int b)
        {
            return a * b / gcd(a, b);
        }

        private static int lcm(List<int> a)
        {
            var res = 1;
            foreach (int el in a)
            {
                res = lcm(res, el);
            }
            return res;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                string s = Console.ReadLine();
               s = s.Replace("VK","*");
                int c = 0;
          //      Console.WriteLine(s);
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == '*')
                        c++;
                }
                if (s.IndexOf("VV") != -1 || s.IndexOf("KK") != -1)
                    c++;
                Console.WriteLine(c);
                Console.ReadKey();
            }
            catch { }
        }

    }
}


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

namespace Lab1cs
{
    class Program
    {

        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            int i = 0, k = 0, j = 0, k1 = 0;
            for (i = 0; i < s.Length - 1; i++)
            {

                if (s.Substring(i, 2) == "VK")
                { k++; i++; }
            }

            if (s.Contains("VV"))
            {
            for (i = 0; i < s.Length - 1; i++)
            {
                string ss = s;
                if (ss.Substring(i, 2) == "VV")
                {
                    ss = ss.Remove(i + 1, 1);
                    ss = ss.Insert(i + 1, "K");

                    for (j = 0; j < s.Length - 1; j++)
                    {

                        if (ss.Substring(j, 2) == "VK")
                        { k1++; j++; }
                    }
                    if (k1 > k)
                        k = k1;
                    k1 = 0;
                }
            }
            }

            if (s.Contains("KK"))
            {
                for (i = 0; i < s.Length - 1; i++)
                {
                    string ss = s;
                    if (ss.Substring(i, 2) == "KK")
                    {
                        ss = ss.Remove(i, 1);
                        ss = ss.Insert(i, "V");

                        for (j = 0; j < s.Length - 1; j++)
                        {

                            if (ss.Substring(j, 2) == "VK")
                            { k1++; j++; }
                        }
                        if (k1 > k)
                            k = k1;
                        k1 = 0;
                    }
                }
            }
                Console.Write(k);
               // Console.ReadKey();

        }
    }
}


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

public sealed class CodeForces
{
    private static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i = 0; i < t; i++)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(Solve(n));
        }
    }

    private static int Solve(int n)
    {
        return (int)Math.Pow(2, n) - 1;
    }
}


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

namespace Codeforces
{
    internal class Program1651A
    {
        static void Main()
        {
            int c = int.Parse(Console.ReadLine());
            while (c-- > 0)
            {
                int n = int.Parse(Console.ReadLine());
                Console.WriteLine(Math.Pow(2, n) - 1);
            }

        }
    }
}


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

namespace CodeForcesRound256
{
    class A
    {
        static void Main(string[] args)
        {
            List<int> c = ReadIntegers();
            List<int> m = ReadIntegers();
            int n = ReadInteger();
            int cups = c.Sum();
            int medals = m.Sum();

            int shelvesForCups = cups / 5;
            if (cups % 5 > 0) shelvesForCups++;

            int shelvesForMedals = medals / 10;
            if (medals % 10 > 0) shelvesForMedals++;

            if (shelvesForMedals + shelvesForCups > n)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");
        }

        private static string ReadLine() { return Console.ReadLine(); }
        private static List<string> ReadStrings() { return ReadLine().Split(" ".ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); }
        private static int ReadInteger() { return int.Parse(Console.ReadLine()); }
        private static List<int> ReadIntegers() { List<int> tmpList = new List<int>(); ReadStrings().ForEach(i => tmpList.Add(int.Parse(i))); return tmpList; }
        private static long ReadLong() { return long.Parse(Console.ReadLine()); }
        private static List<long> ReadLongs() { List<long> tmpList = new List<long>(); ReadStrings().ForEach(i => tmpList.Add(long.Parse(i))); return tmpList; }
    }
}


    using System;

    namespace Issue_448A
    {
        class Program
        {
            public static void Main(string[] args) {
                const byte Places = 3;

                var cups = new int[Places];
                var medals = new int[Places];

                for (int i = 0; i < Places; ++i) {
                    cups[i] = ReadInt();
                }

                for (int i = 0; i < Places; ++i) {
                    medals[i] = ReadInt();
                }

                var shelfs_count = ReadInt();

                var required_shelfs =
                    cups[0] / 5 +
                    cups[1] / 5 +
                    cups[2] / 5 +
                    (cups[0] % 5 + cups[1] % 5 + cups[2] % 5) / 5 +
                    (((cups[0] % 5 + cups[1] % 5 + cups[2] % 5) % 5) > 0 ? 1 : 0) +
                    medals[0] / 10 +
                    medals[1] / 10 +
                    medals[2] / 10 +
                    (medals[0] % 10 + medals[1] % 10 + medals[2] % 10) / 10 +
                    ((((medals[0] % 10 + medals[1] % 10 + medals[2] % 10) % 10) % 10) > 0 ? 1 : 0);

                Console.WriteLine(required_shelfs <= shelfs_count ? "YES" : "NO");
            }

            private static bool IsInputError = false;
            private static bool IsEndOfLine = false;

            private static int ReadInt() {
                const int zeroCode = (int) '0';

                var result = 0;
                var isNegative = false;
                var symbol = Console.Read();
                IsInputError = false;
                IsEndOfLine = false;

                while (symbol == ' ') {
                    symbol = Console.Read();
                }

                if (symbol == '-') {
                    isNegative = true;
                    symbol = Console.Read();
                }

                for ( ;
                    (symbol != -1) && (symbol != ' ');
                    symbol = Console.Read()
                ) {
                    var digit = symbol - zeroCode;

                    // if symbol == \n
                    if (symbol == 13) {
                        // skip next \r symbol
                        Console.Read();
                        IsEndOfLine = true;
                        break;
                    }

                    if (digit < 10 && digit >= 0) {
                        var cache1 = result << 1;
                        var cache2 = cache1 << 2;
                        result = cache1 + cache2 + digit;
                    } else {
                        IsInputError = true;
                        break;
                    }
                }

                return isNegative ? ~result + 1 : result;
            }
        }
    }


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            int t = int.Parse(Console.ReadLine());
            for (int i = 0; i < t; i++)
            {

                int x = int.Parse(Console.ReadLine());
                if (x==1 || x==2 ||x==4 ||x==5 || x==8 ||x==11)
                {

                    Console.WriteLine("NO");

                }
                else
                {
                    Console.WriteLine("YES");
                }
            }
        }
    }
}


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

namespace AlgoTasks
{
    class Program
    {
        static void Main(string[] args)
        {
            short n = short.Parse(Console.ReadLine());
            //2
            //6
            //5
            //yes
            //no

            for (short i = 0; i < n; i++)
            {
                short x = short.Parse(Console.ReadLine());
                bool yes = false;

                short t = x;
                while(t >= 7)
                {
                    if (t % 7 == 0 || t % 3 == 0)
                    {
                        yes = true;
                        break;
                    }
                    t -= 3;
                }

                t = x;
                while (t >= 3)
                {
                    if (t % 7 == 0 || t % 3 == 0)
                    {
                        yes = true;
                        break;
                    }
                    t -= 7;
                }

                if (yes)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}


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

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

            string read;
            read = Console.ReadLine();
            List<int> ArrayA = new List<int>();
            ArrayA = (read.Split(' ').ToList()).Select(s => int.Parse(s)).ToList();

            HashSet<int> hashit = new HashSet<int>();

            for(int i = n-1;i>=0;i--)
            {
                if(!hashit.Contains(ArrayA[i]))
                {
                    hashit.Add(ArrayA[i]);
                }
            }
            Console.WriteLine(hashit.Count);
            Console.WriteLine(String.Join(" ",hashit.Reverse().ToList()));

        }
    }
}


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

namespace _978A
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            var n = rl<int>();
            var arr = rlai();
            var res = new List<int>();
            var hs = new HashSet<int>();

            for (var i = arr.Length - 1; i >= 0; i--)
            {
                if (!hs.Contains(arr[i]))
                {
                    hs.Add(arr[i]);
                    res.Insert(0, arr[i]);
                }
            }

            wl(res.Count);
            wla(res.ToArray());
        }

        private static T rl<T>() { return (T)Convert.ChangeType(Console.ReadLine(), typeof(T)); }
        private static T[] rla<T>(char sep = ' ') { return Console.ReadLine().Split(sep).Select(s => (T)Convert.ChangeType(s, typeof(T))).ToArray(); }
        private static int[] rlai(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), int.Parse); }
        private static long[] rlal(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), long.Parse); }
        private static string[] rlas(char sep = ' ') { return Console.ReadLine().Split(sep); }
        private static List<T> rll<T>(char sep = ' ') { return Console.ReadLine().Split(sep).Select(s => (T)Convert.ChangeType(s, typeof(T))).ToList(); }
        private static T rn<T>(char sep = ' ') { var b = new StringBuilder(); while (true) { var c = (char)Console.In.Read(); if (c == sep || c == '\n') break; b.Append(c); } return (T)Convert.ChangeType(b.ToString(), typeof(T)); }
        private static void wl(object o) { Console.WriteLine(o); }
        private static void wla(int[] arr, string sep = " ") { Console.WriteLine(string.Join(sep, arr)); }
        private static void wla(long[] arr, string sep = " ") { Console.WriteLine(string.Join(sep, arr)); }
        private static void wla(string[] arr, string sep = " ") { Console.WriteLine(string.Join(sep, arr)); }
        private static void w(object o) { Console.Write(o); }
        private static void wn(object o, string sep = " ") { Console.Write(o + sep); }
    }
}


// Submitted by Stratholme @ Macau
using System;
using System.IO;
using System.Collections.Generic;
using CCF_XOI;

namespace CodeForces
{
	class CF456C
	{
		public void Solve(XOI xoi)
		{
			int N, i, j, k, ans;
			long[] hash = new long[2];
			List<int>[] K = new List<int>[2];
			HashSet<Tuple<long, long>> comb = new HashSet<Tuple<long, long>>();

			N = xoi.ReadInt();
			for (i = 0; i < 2; i++)
			{
				K[i] = new List<int>();
				k = xoi.ReadInt();
				for (j = 0; j < k; j++)
					K[i].Add(xoi.ReadInt());
			}

			for (ans = 0; ; ans++)
			{
				if (K[0].Count == 0) { k = 2; break; }
				if (K[1].Count == 0) { k = 1; break; }

				k = (K[0][0] > K[1][0] ? 0 : 1);
				K[k].Add(K[1 - k][0]);
				K[k].Add(K[k][0]);
				K[k].RemoveAt(0);
				K[1 - k].RemoveAt(0);

				for (i = 0; i < 2; i++)
				{
					for (j = 0, hash[i] = 0; j < N; j++)
					{
						hash[i] *= 11;
						if (j < K[i].Count)
							hash[i] += K[i][j];
					}
				}
				if (!comb.Add(Tuple.Create(hash[0], hash[1])))
				{
					ans = -1;
					break;
				}
			}

			if (ans == -1)
				xoi.o.WriteLine("-1");
			else
				xoi.o.WriteLine("{0} {1}", ans, k);
		}
	}

	class CodeForcesMain
	{
		static void Main(string[] args)
		{
			(new CF456C()).Solve(new XOI());
		}
	}
}

namespace CCF_XOI
{	// version 2014.06.20
	class XOI
	{
		protected StreamReader sr;
		public StreamWriter o;
		protected Queue<string> buf = new Queue<string>();
		public bool EOF = false;

		public XOI()
		{
			this.sr = new StreamReader(Console.OpenStandardInput());
			this.o = new StreamWriter(Console.OpenStandardOutput());
			this.o.AutoFlush = true;
		}

		public XOI(string in_path, string out_path)
		{
			this.sr = new StreamReader(in_path);
			this.o = new StreamWriter(out_path);
			this.o.AutoFlush = true;
		}

		public int ReadInt()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int32.Parse(s);
		}

		public long ReadLong()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int64.Parse(s);
		}

		public double ReadDouble()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
		}

		public string ReadString()
		{
			string s = this.GetNext();
			return (s == null ? null : s);
		}

		public string ReadLine()
		{	// I will ignore current buffer and read a new line
			string s = "";
			while (s == "" && !this.EOF)
			{
				s = sr.ReadLine();
				this.EOF = (s == null);
			}
			return (this.EOF ? null : s);
		}

		protected string GetNext()
		{
			if (buf.Count == 0)
			{
				while (buf.Count == 0 && !this.EOF)
				{
					string s = sr.ReadLine();
					if (s == null)
						this.EOF = true;
					else
						foreach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
							buf.Enqueue(ss);
				}
			}

			return (this.EOF ? null : buf.Dequeue());
		}
	}
}


// Submitted by Silithus @ Macau
using System;
using System.IO;
using System.Collections.Generic;
using CCF_XOI;

namespace CodeForces
{
	class CF456C
	{
		public void Solve(XOI xoi)
		{
			int N, i, j, k, ans;
			long[] hash = new long[2];
			List<int>[] K = new List<int>[2];
			HashSet<Tuple<long, long>> comb = new HashSet<Tuple<long, long>>();

			N = xoi.ReadInt();
			for (i = 0; i < 2; i++)
			{
				K[i] = new List<int>();
				k = xoi.ReadInt();
				for (j = 0; j < k; j++)
					K[i].Add(xoi.ReadInt());
			}

			for (ans = 0; ; ans++)
			{
				if (K[0].Count == 0) { k = 2; break; }
				if (K[1].Count == 0) { k = 1; break; }

				k = (K[0][0] > K[1][0] ? 0 : 1);
				K[k].Add(K[1 - k][0]);
				K[k].Add(K[k][0]);
				K[k].RemoveAt(0);
				K[1 - k].RemoveAt(0);

				for (i = 0; i < 2; i++)
				{
					for (j = 0, hash[i] = 0; j < N; j++)
					{
						hash[i] *= 11;
						if (j < K[i].Count)
							hash[i] += K[i][j];
					}
				}
				if (!comb.Add(Tuple.Create(hash[0], hash[1])))
				{
					ans = -1;
					break;
				}
			}

			if (ans == -1)
				xoi.o.WriteLine("-1");
			else
				xoi.o.WriteLine("{0} {1}", ans, k);
		}
	}

	class CodeForcesMain
	{
		static void Main(string[] args)
		{
			(new CF456C()).Solve(new XOI());
		}
	}
}

namespace CCF_XOI
{	// version 2014.06.20
	class XOI
	{
		protected StreamReader sr;
		public StreamWriter o;
		protected Queue<string> buf = new Queue<string>();
		public bool EOF = false;

		public XOI()
		{
			this.sr = new StreamReader(Console.OpenStandardInput());
			this.o = new StreamWriter(Console.OpenStandardOutput());
			this.o.AutoFlush = true;
		}

		public XOI(string in_path, string out_path)
		{
			this.sr = new StreamReader(in_path);
			this.o = new StreamWriter(out_path);
			this.o.AutoFlush = true;
		}

		public int ReadInt()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int32.Parse(s);
		}

		public long ReadLong()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Int64.Parse(s);
		}

		public double ReadDouble()
		{
			string s = this.GetNext();
			if (s == null) return -1;
			else return Double.Parse(s, System.Globalization.CultureInfo.InvariantCulture);
		}

		public string ReadString()
		{
			string s = this.GetNext();
			return (s == null ? null : s);
		}

		public string ReadLine()
		{	// I will ignore current buffer and read a new line
			string s = "";
			while (s == "" && !this.EOF)
			{
				s = sr.ReadLine();
				this.EOF = (s == null);
			}
			return (this.EOF ? null : s);
		}

		protected string GetNext()
		{
			if (buf.Count == 0)
			{
				while (buf.Count == 0 && !this.EOF)
				{
					string s = sr.ReadLine();
					if (s == null)
						this.EOF = true;
					else
						foreach (string ss in s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
							buf.Enqueue(ss);
				}
			}

			return (this.EOF ? null : buf.Dequeue());
		}
	}
}


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

namespace ConsoleApplication2
{
    class Program
    {
        public static int[] criba = new int[60],primos = new int[60];
        public static int pP = 0;

        static void Main(string[] args)
        {
            cribad();
            bool y = false;
            int[] nm = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            for (int i = 0; i < primos.Length; i++)
            {
                if (primos[i] == nm[0] && primos[i + 1] == nm[1])
                {
                    y = true;
                    break;
                }
            }
            Console.Write(y ? "YES":"NO");
            Console.Read();
        }

        public static void cribad()
        {
            int i, j;
            for (i = 2; i < 60; i++)
            {
                if (criba[i] != 1)
                {
                    primos[pP++] = i;
                    for (j = i * i; j < 60; j += i)
                        criba[j] = 1;
                }
            }
        }
    }
}


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

namespace capp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));
            int n = data[0];
            int m = data[1];
            for (int i = n + 1; i <m; i++)
                if (IsSimple(i))
                {
                    Console.WriteLine("NO");
                    return;
                }
            if (IsSimple(m) &&  m>n)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }

        static bool IsSimple(int a)
        {
            for (int i = 2; i < a - 1; i++)
                if (a % i == 0)
                    return false;
            return true;
        }
    }

}


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

namespace ConsoleApplication1
{
    class Program
    {
        const int N = 101;
        const int K = 51;
        const int INF = 1000 * 1000 * 1000;
        private static void solve()
        {
            int a = GetInt();
            int b = GetInt();
            int win = 0, lose = 0, draw = 0;
            for (int i = 1; i <= 6; ++i)
            {
                if (Math.Abs(a - i) < Math.Abs(b - i))
                    win++;
                else if (Math.Abs(a - i) > Math.Abs(b - i))
                    lose++;
                else
                    draw++;
            }
            Console.WriteLine(win + " " + draw + " " +  lose);
        }
        public static void Main()
        {
            solve();
        }

        private static  int pos = 0;
        private static string[] st;
        private static string GetString()
        {
            if (st == null || pos == st.Length)
            {
                st = Console.ReadLine().Split(' ');
                pos = 0;
            }
            return st[pos++];
        }
        private static int GetInt()
        {
            return int.Parse(GetString());
        }
        private static double GetDouble()
        {
            return double.Parse(GetString(), CultureInfo.InvariantCulture);
        }
        private static long GetLong()
        {
            return long.Parse(GetString());
        }
    }
}


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

namespace probleme {
    class Program {
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]), b = int.Parse(s[1]);
            if (a == b) {
                Console.WriteLine("0 6 0");
            } else if (a < b) {
                int med = (a + b) / 2;
                if ((b - a) % 2 == 0) {
                    Console.WriteLine("{0} {1} {2}", med - 1, 1, 6 - med);
                } else {
                    Console.WriteLine("{0} {1} {2}", med, 0, 6 - med);
                }
            } else {
                int med = (a + b) / 2;
                if ((a - b) % 2 == 0) {
                    Console.WriteLine("{0} {1} {2}", 6 - med, 1, med - 1);
                } else {
                    Console.WriteLine("{0} {1} {2}", 6 - med, 0, med);
                }
            }
            // Console.ReadKey();
        }
    }
}


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

namespace ConsoleApplication78
{
    class Program
    {
        static public long res = 0;
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(q => long.Parse(q)).ToArray();
            gcd(a[0], a[1]);
            Console.WriteLine(res);
        }
        static public long gcd(long x, long y)
        {
            if (y == 0) return x;
             res += x / y;
            return gcd(y, x % y);
        }
    }
}


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

namespace A.Игра_с_бумагой
{
    class Program
    {
        static void Main(string[] args)
        {
            var mas = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long a = mas[0];
            long b = mas[1];
            long k = 0;

            while(a != 0 & b != 0)
            {
                if (a >= b)
                {
                    k += a / b;
                    a = a % b;
                }
                else //if (b > a)
                {
                    k += b / a;
                    b = b % a;
                }
            }

            Console.WriteLine(k);
            Console.ReadLine();
        }
    }
}


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{
	long gcd(long a, long b){ return a == 0 ? b : gcd(b % a, a);}
	public void Solve(){
try{
checked{

		long mo = N * K;
		List<long> X = new List<long>(){
			A, (mo - A) % mo
		};
		long ma = -1, mi = (long) 1e18;
		foreach(var s in X){
			for(int i=0;i<N;i++){
				long bb = i * K;
				for(int j=-1;j<=1;j+=2){
					long b = (bb + j * B) % mo;
					long l = b - s;
					if(l < 0){
						l %= mo;
						l += mo;
					}
					if(l == 0){
						l = mo;
					}
//Console.WriteLine("s:{0}, l:{1}, mo:{2}, gcd:{3}",s, l, mo, gcd(mo, l));
					//var lcm = mo / gcd(mo, l) * l;
//Console.WriteLine("lcm:{0}, l:{1}",lcm, l);
					//var rr = lcm / l;
					var rr = mo / gcd(mo, l);
					ma = Math.Max(ma, rr);
					mi = Math.Min(mi, rr);
				}
			}
		}
		Console.WriteLine("{0} {1}",mi, ma);
}
} catch (Exception e){
	Console.WriteLine(e);
	return;
}

	}
	long N,K;
	long A,B;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		d = ria();
		A = d[0]; B = d[1];
	}

	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;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long K = long.Parse(str[1]);
		string[] str2 = Console.ReadLine().Split();
		long A = long.Parse(str2[0]);
		long B = long.Parse(str2[1]);
		long min = 999999999999999;
		long max = 0;
		for(var i=0;i<N;i++){
			long a1 = Math.Abs(i*K+B - A);
			if(a1==0){
				min = 1;
			} else {
				min = Math.Min(min,N*K/Gcd(a1,N*K));
			}
			max = Math.Max(max,N*K/Gcd(a1,N*K));
			long a2 = Math.Abs(i*K+B + A);
			min = Math.Min(min,N*K/Gcd(a2,N*K));
			max = Math.Max(max,N*K/Gcd(a2,N*K));
		}
		Console.WriteLine(min+" "+max);
	}
	public static long Lcm(long a, long b) {
        return a * b / Gcd(a, b);
    }

	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}


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

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      int n = input.NextInt();
      int[] d = { 8, 4, 2, 6 };
      int k;
      if (n == 0)
        k = 1;
      else
        k = d[(n - 1) % 4];
      Console.Write(k);
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public int NextInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      bool isNegative = false;
      if(c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      int result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long NextLong()
    {
      return long.Parse(this.NextToken());
    }

    public double NextDouble()
    {
      return double.Parse(this.NextToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = NextInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = NextLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      double[] a = new double[n];
      for (int i = 0; i < n; i++)
        a[i] = NextDouble();
      return a;
    }

    public string NextToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      int c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}


//
// 742A Codeforces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,op;
            n = Convert.ToInt32(Console.ReadLine());
            op = n % 4;
            if(n == 0)
            {
                Console.WriteLine("1\n");
                return;
            }
            switch (op)
            {
                case 0:
                    Console.WriteLine("6\n");
                    break;
                case 1:
                    Console.WriteLine("8\n");
                    break;
                case 2:
                    Console.WriteLine("4\n");
                    break;
                case 3:
                    Console.WriteLine("2\n");
                    break;
                default:
                    Console.WriteLine("\n");
                    break;
            }
        }
    }
}


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

namespace Brauzer
{
    class Program
    {
        private static int CalculateTime(int n,int pos,int l, int r)
        {
            if (l == 1 && r == n) return 0;
            int count = 0;
            if (l > 1 && r < n) count += r - l;
            if (pos >= l && pos <= r)
            {
                if (l == 1)
                    count += r - pos+1;
                else
                    if (r == n) count += pos - l+1; else count += Math.Min(r - pos, pos - l)+2;
                return count;
            }

            if (pos < l || (pos == l && l > 1))
            {
                count += l - pos+1;
                if (r < n) count++;
                return count;
            }

            if (pos > r || (pos == r && r < n))
            {
                count += pos - r+1;
                if (l > 1) count++;
            }

            return count;
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();

            int n = int.Parse(s[0]);
            int pos = int.Parse(s[1]);
            int l = int.Parse(s[2]);
            int r = int.Parse(s[3]);

            Console.Write(CalculateTime(n,pos,l,r));

        }
    }
}


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

namespace Browser
{
    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)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int n = Next(), pos = Next(), l = Next(), r = Next();

            if (l == 1 && r == n)
                return 0;
            if (l == 1)
            {
                if (pos <= r)
                {
                    return r - pos + 1;
                }
                return pos - r + 1;
            }
            if (r == n)
            {
                if (pos >= l)
                    return pos - l + 1;
                return l - pos + 1;
            }
            if (pos <= l)
            {
                return r - pos + 2;
            }
            if (pos >= r)
            {
                return pos - l + 2;
            }
            return 2 + r - l + Math.Min(r - pos, pos - l);
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Linq;

namespace _624B
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
            long ans = s[0], mark = s[0];
            for (int i = 1; i<s.Length;i++)
            {
                if (s[i] < mark) { ans += s[i]; mark = s[i]; }
                else if (mark > 1)
                {
                    mark--; ans += mark;
                }
                else break;
            }
            Console.WriteLine(ans);
        }
    }
}