using System;

namespace Task_D
{
    class Solution
    {
        static void Main(string[] args)
        {
            new Solution().Solve();
        }

        private int n;
        private int d;
        private long x;
        private int[] a;
        private int[] b;
        private int[] c;

        private void Solve()
        {
            var parts = Console.ReadLine().Split();
            n = int.Parse(parts[0]);
            d = int.Parse(parts[1]);
            x = long.Parse(parts[2]);

            a = new int[n];
            b = new int[n];
            c = new int[n];

            initAB();

            var bCount = 0;
            var bPos = new int[n];
            for (int i = 0; i < n; i++)
            {
                if (b[i] == 1)
                {
                    bPos[bCount++] = i;
                }
            }

            var aOrder = new int[n];
            for (int i = 0; i < n; i++)
            {
                aOrder[a[i] - 1] = i;
            }

            int s = 50;

            for (int i = 0; i < n; i++)
            {
                for (int q = 0; q < s && q < n; q++)
                {
                    int j = aOrder[n - q - 1];
                    if (i - j >= 0 && b[i - j] == 1)
                    {
                        c[i] = a[j];
                        break;
                    }
                }

                if (c[i] != 0)
                {
                    continue;
                }

                for (int z = 0; z < bCount; z++)
                {
                    var bIndex = bPos[z];
                    var j = i - bIndex;
                    if (j >= 0)
                    {
                        c[i] = Math.Max(c[i], a[j]);
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(c[i]);
            }
        }

        private long getNextX()
        {
            x = (x * 37 + 10007) % 1000000007;
            return x;
        }

        private void initAB()
        {
            for (int i = 0; i < n; i = i + 1)
            {
                a[i] = i + 1;
            }

            for (int i = 0; i < n; i = i + 1)
            {
                swap(ref a[i], ref a[getNextX() % (i + 1)]);
            }

            for (int i = 0; i < n; i = i + 1)
            {
                if (i < d)
                    b[i] = 1;
                else
                    b[i] = 0;
            }

            for (int i = 0; i < n; i = i + 1)
            {
                swap(ref b[i], ref b[getNextX() % (i + 1)]);
            }
        }

        private void swap<T>(ref T first, ref T second)
        {
            T tmp = first;
            first = second;
            second = tmp;
        }
    }
}


using System;
using System.Linq;

namespace Preparation
{
    public class CodeForces710E
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            long n = input[0];
            long x = input[1];
            long y = input[2];
            long[] arr = new long[n];
            arr[0] = x;
            for (int i = 0; i < n - 1; ++i)
            {
                arr[i + 1] = arr[i + 1] == 0 ? arr[i] + x : Math.Min(arr[i + 1], arr[i] + x);
                long ind = (i + 1)*2 - 1;
                var t = y;
                if (ind >= n)
                {
                    t += arr[ind - n];
                    ind = n - 1;
                }
                arr[ind] = arr[ind] == 0 ? arr[i] + t : Math.Min(arr[ind], arr[i] + t);
                arr[ind-1] = arr[ind-1] == 0 ? arr[i] + t + x : Math.Min(arr[ind-1], arr[i] + t + x);
            }

            Console.WriteLine(arr[n-1]);
        }
}
    }


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

namespace CSharp
{
    class A441
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine()), b = int.Parse(Console.ReadLine()), c = int.Parse(Console.ReadLine());
            int mab = Math.Min(a, b);
            int mabc = Math.Min(mab, c);
            int ans = 0;
            if (n == 2)
            {
                ans = mab;
            }
            else if (n > 2)
            {
                ans = mab + (n - 2) * mabc;
            }
            Console.WriteLine(ans);
        }
    }
}


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

namespace ProgrammingContest.Codeforces.Round59
{
    class C
    {
        int n;
        int[][] dat;
        int count;
        int res;

        bool ok(int id, params int[] xs)
        {
            int a = 0, b = 0;
            int[] pos = new int[10];
            for (int i = 0; i < 10; i++)
                pos[i] = -1;
            for (int i = 0; i < 4; i++)
                pos[xs[i]] = i;
            for (int m = dat[id][0], i = 3; i >= 0; i--, m /= 10)
            {
                if (pos[m % 10] == i) a++;
                else if (pos[m % 10] >= 0) b++;
            }
            //for (int i = 0; i < 4; i++)
            //    Console.Write("{0} ", xs[i]);
            //Console.WriteLine(": {0} {1} : {2} {3}", a, b, dat[id][1], dat[id][2]);
            return a == dat[id][1] && b == dat[id][2];
        }

        C()
        {
            n = int.Parse(Console.ReadLine());
            dat = new int[n][];
            for (int i = 0; i < n; i++)
                dat[i] = Array.ConvertAll(Console.ReadLine().Split(' '), sss => int.Parse(sss));

            for (int a = 0; a < 10; a++)
                for (int b = 0; b < 10; b++)
                    if (a != b)
                        for (int c = 0; c < 10; c++)
                            if (a != c && b != c)
                                for (int d = 0; d < 10; d++)
                                    if (a != d && b != d && c != d)
                                    {
                                        bool chk = true;
                                        for (int i = 0; i < n; i++)
                                            chk &= ok(i, a, b, c, d);
                                        if (chk)
                                        {
                                            count++;
                                            res = a * 1000 + b * 100 + c * 10 + d;
                                        }
                                    }

            Console.WriteLine(count == 0 ? "Incorrect data" : (count != 1 ? "Need more data" : res.ToString("0000")));
        }

        public static void Main()
        {
            new C();
        }
    }
}


using System;
using System.Collections;

namespace _1032A
{
    class Program
    {
        static void Main(string[] args)
        {
            string strFirstInput;
            string strSecondInput;
            string[] strFirstSplit;
            string[] strSecondSplit;

            long nUtensilsRemaining;
            long nGuests;
            long nMissingUtensils = 0;
            long[] nUtensils;
            long nDishes;
            long nPotentialUtensils;
            long nTemp;
            long nSet = 1;
            long nMax = 0;

            Hashtable hUtensils;

            strFirstInput = Console.ReadLine();
            strSecondInput = Console.ReadLine();

            strFirstSplit = strFirstInput.Split(new char[0]);
            strSecondSplit = strSecondInput.Split(new char[0]);

            nGuests = long.Parse(strFirstSplit[1].ToString());
            nUtensilsRemaining = long.Parse(strFirstSplit[0].ToString());

            hUtensils = new Hashtable();
            nUtensils = new long[nUtensilsRemaining]; // Is this even required?

            for(int i = 0; i < nUtensilsRemaining; i++)
            {
                nUtensils[i] = long.Parse(strSecondSplit[i].ToString());

                try
                {
                    hUtensils.Add(strSecondSplit[i].ToString(), 1);
                } catch (Exception ex)
                {
                    hUtensils[strSecondSplit[i].ToString()] = Convert.ToInt64(hUtensils[strSecondSplit[i].ToString()]) + 1;
                }
            }

            nDishes = hUtensils.Count;

            foreach (DictionaryEntry dct in hUtensils)
            {
                nTemp = Convert.ToInt64(dct.Value);

                if (nTemp > nMax) nMax = nTemp;
            }

            if (nMax / nGuests == 1 && nMax % nGuests > 0) nSet++;
            if (nMax / nGuests > 1)
            {
                nSet += nMax / nGuests;
                if (nMax % nGuests > 0) nSet++;
            }

            nPotentialUtensils = nDishes * nGuests * (nSet > 2 ? nSet - 1: nSet);
            nMissingUtensils = nPotentialUtensils - nUtensilsRemaining;
            Console.WriteLine(nMissingUtensils);
        }
    }
}


using System;

namespace CSharp
{
    class _976B
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            long n = long.Parse(tokens[0]);
            long m = long.Parse(tokens[1]);
            long k = long.Parse(tokens[2]);

            if (k < n)
            {
                Console.WriteLine($"{1 + k} 1");
            }
            else
            {
                k -= n;
                m--;

                long row = n - k / m;
                long column = (n - row) % 2 == 0 ? 2 + k % m : m + 1 - k % m;

                Console.WriteLine($"{row} {column}");
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace G.GangUp
{
    internal static class Program
    {
        public static void Main(string[] args)
        {
            var nmkcd = Console.ReadLine().Split();
            var n = int.Parse(nmkcd[0]);
            var m = int.Parse(nmkcd[1]);
            var k = int.Parse(nmkcd[2]);
            var c = int.Parse(nmkcd[3]);
            var d = int.Parse(nmkcd[4]);

            var solver = new Solver(n, m, k, c, d);
            solver.Init();

            ReadInput(solver, n, m);

            for (var i = 0; i < k; i++)
                solver.IncreaseFlow();

            Console.WriteLine(solver.TotalCost);
        }

        private static void ReadInput(Solver solver, int n, int m)
        {
            var memberCounts = new int[n];
            foreach (var memberHome in Console.ReadLine().Split())
                memberCounts[int.Parse(memberHome) - 1]++;

            for (var crossroad = 0; crossroad < n; crossroad++)
                solver.AddMemberHome(crossroad, memberCounts[crossroad]);

            for (var i = 0; i < m; i++)
            {
                var xy = Console.ReadLine().Split();
                var x = int.Parse(xy[0]) - 1;
                var y = int.Parse(xy[1]) - 1;

                solver.AddEdge(x, y);
                solver.AddEdge(y, x);
            }
        }
    }

    internal sealed class Solver
    {
        private static readonly Edge FakeEdge = new Edge();

        private readonly int _n, _m, _k, _c, _d;
        private readonly int _maxTime;
        private readonly Node _start, _sink;
        private readonly Node[,] _nodes;
        private readonly List<Edge>[] _nodeEdges;
        private readonly BestPathSearcher _bestPathSearcher;

        public Solver(int n, int m, int k, int c, int d)
        {
            _n = n;
            _m = m;
            _k = k;
            _c = c;
            _d = d;

            _maxTime = k + m;
            _nodes = new Node[n, _maxTime];

            _start = new Node() {Id = _nodes.Length};
            _sink = new Node() {Id = _nodes.Length + 1};

            var allNodesCount = _nodes.Length + 2;

            _nodeEdges = new List<Edge>[allNodesCount];
            for (var i = 0; i < allNodesCount; i++)
                _nodeEdges[i] = new List<Edge>(_maxTime);

            _bestPathSearcher = new BestPathSearcher(_nodeEdges);
        }

        public int TotalCost { get; private set; }

        public void Init()
        {
            var nodeId = 0;
            for (var node = 0; node < _n; node++)
                for (var time = 0; time < _maxTime; time++)
                    _nodes[node, time] = new Node() { Id = nodeId++ };

            for (var time = 0; time < _maxTime; time++)
                AddEdgeWithoutPair(_nodes[0, time], _sink, time * _c, _k);

            for (var node = 0; node < _n; node++)
            {
                var from = _nodes[node, 0];
                for (var time = 1; time < _maxTime; time++)
                {
                    var to = _nodes[node, time];
                    AddEdgePair(from, to, 0, _k);
                    from = to;
                }
            }
        }

        public void AddMemberHome(int home, int count)
        {
            if (count > 0)
                AddEdgeWithoutPair(_start, _nodes[home, 0], 0, count);
        }

        public void AddEdge(int from, int to)
        {
            for (var time = 0; time < _maxTime - 1; time++)
            {
                var nodeFrom = _nodes[from, time];
                var nodeTo = _nodes[to, time + 1];

                for (int people = 0, cost = 1; people < _k; people++, cost += 2)
                    AddEdgePair(nodeFrom, nodeTo, cost * _d, 1);
            }
        }

        public void IncreaseFlow()
        {
            var bestPath = _bestPathSearcher.FindBestPath(_start, _sink);
            foreach (var edge in bestPath)
            {
                edge.ResidualCapacity--;
                edge.PairedEdge.ResidualCapacity++;
                TotalCost += edge.Cost;
            }
        }

        private void AddEdgePair(Node from, Node to, int cost, int capacity)
        {
            var forwardEdge = new Edge()
            {
                From = from,
                To = to,
                Cost = cost,
                ResidualCapacity = capacity,
            };

            var reverseEdge = new Edge()
            {
                From = to,
                To = from,
                Cost = -cost,
                ResidualCapacity = 0,
            };

            forwardEdge.PairedEdge = reverseEdge;
            reverseEdge.PairedEdge = forwardEdge;

            _nodeEdges[from.Id].Add(forwardEdge);
            _nodeEdges[to.Id].Add(reverseEdge);
        }

        private void AddEdgeWithoutPair(Node from, Node to, int cost, int capacity)
        {
            _nodeEdges[from.Id].Add(new Edge()
            {
                From = from,
                To = to,
                Cost = cost,
                ResidualCapacity = capacity,
                PairedEdge = FakeEdge,
            });
        }
    }

    internal sealed class BestPathSearcher
    {
        private readonly List<Edge>[] _nodeEdges;

        private readonly int[] _bestCosts;
        private readonly Edge[] _bestMoves;
        private readonly bool[] _isInQueue;
        private readonly Queue<Node> _bestPathSearchQueue;

        public BestPathSearcher(List<Edge>[] nodeEdges)
        {
            _nodeEdges = nodeEdges;
            _bestCosts = new int[nodeEdges.Length];
            _bestMoves = new Edge[nodeEdges.Length];
            _isInQueue = new bool[nodeEdges.Length];
            _bestPathSearchQueue = new Queue<Node>(nodeEdges.Length);
        }

        public IEnumerable<Edge> FindBestPath(Node start, Node to)
        {
            for (var i = 0; i < _bestCosts.Length; i++)
                _bestCosts[i] = int.MaxValue;

            _bestCosts[start.Id] = 0;
            _bestPathSearchQueue.Enqueue(start);

            while (_bestPathSearchQueue.Count > 0)
            {
                var node = _bestPathSearchQueue.Dequeue();
                var costToNode = _bestCosts[node.Id];

                foreach (var edge in _nodeEdges[node.Id])
                {
                    if (edge.ResidualCapacity == 0)
                        continue;

                    var possibleCost = costToNode + edge.Cost;
                    if (possibleCost >= _bestCosts[edge.To.Id])
                        continue;

                    _bestCosts[edge.To.Id] = possibleCost;
                    _bestMoves[edge.To.Id] = edge;
                    if (_isInQueue[edge.To.Id])
                        continue;

                    _isInQueue[edge.To.Id] = true;
                    _bestPathSearchQueue.Enqueue(edge.To);
                }

                _isInQueue[node.Id] = false;
            }

            var cur = _bestMoves[to.Id];
            while (cur != null)
            {
                yield return cur;
                cur = _bestMoves[cur.From.Id];
            }
        }
    }

    internal struct Node
    {
        public int Id { get; set; }
        public override string ToString() => Id.ToString();
    }

    internal sealed class Edge
    {
        public Node From { get; set; }
        public Node To { get; set; }
        public int Cost { get; set; }
        public int ResidualCapacity { get; set; }
        public Edge PairedEdge { get; set; }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
public class CodeForces
{
#if TEST
    // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
    const bool testing = true;
#else
const bool testing = false;
#endif

    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';
        }
    }
    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);

    struct Point
    {
        public int x { get; set; }
        public int y { get; set; }
    }
    static void program(TextReader input)
    {
        //var n = int.Parse(input.ReadLine().TrimEnd());
        var data = input.ReadLine().Split(' ').Select(int.Parse).ToList();
        var x1 = data[0];
        var y1 = data[1];
        var data2 = input.ReadLine().Split(' ').Select(int.Parse).ToList();
        var x2 = data2[0];
        var y2 = data2[1];

        var points = new List<Point>();
        var stepX = new int[] { -1, 0, 1, 1, 1, 0, -1, -1 };
        var stepY = new int[] { 1, 1, 1, 0, -1, -1, -1, 0 };
        var min = int.MaxValue;
        for(var i = 0; i < stepX.Length; i++)
        {
            var distance = Math.Abs(x1 - (x2 + stepX[i])) + Math.Abs(y1 - (y2 + stepY[i]));
            min = Math.Min(min, distance);
        }

        writer.WriteLine(2*min + 8);
        writer.Flush();
    }

    public static void Main(string[] args)
    {
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("18\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("1 5\n5 2\n"));
        Console.WriteLine();
        Console.ReadLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("8\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("0 1\n0 0\n"));
        Console.WriteLine();
        Console.ReadLine();

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var cnt = sc.Long(2);
            var sum = cnt.Sum();
            var a = sc.Integer();
            var b = sc.Integer();
            var l = sum;
            var r = (long)1e10;
            while (l <= r)
            {
                var m = (l + r) >> 1;
                var k = m / a;
                var u = m / b;
                var v = m / (a * b);
                var rem = m - k - u + v;
                rem += Math.Min(cnt[1], k - v);
                rem+=Math.Min(cnt[0],u-v);
                if (rem>= sum)
                    r = m - 1;
                else l = m + 1;
            }
            IO.Printer.Out.WriteLine(l);
        }
        internal IO.StreamScanner sc;
    }
    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                IO.Printer.Out.AutoFlush = true;
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    //if (buf[ptr] < lb || ub < buf[ptr])
                    if (buf[ptr] == cr || buf[ptr] == el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, f, len - f));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion
#region gcd,lcm
static public partial class MathEx
{

    static public long GCD(long x, long y)
    {
        byte i = 0;
        while (x != 0 && y != 0)
        {
            if (i == 0)
                y %= x;
            else x %= y;
            i ^= 1;
        }
        return x == 0 ? y : x;
    }

}
#endregion


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

namespace _5Dproblem
{
    class vector
    {
        private int[] points= new int[5];
        private double length ;

        public vector(Point R,Point D)
        {
            for (int i = 0; i < 5; i++)
            {
                points[i] = R.coordinates[i]-D.coordinates[i];
            }
            length = Math.Sqrt(vector.CrossProduct(this, this));
        }

        public double GetLength()
        {
            return length;
        }
        static public double CrossProduct(vector A,vector B)
        {
            double product = 0;
            product = A.points[0] * B.points[0]
                + A.points[1] * B.points[1]
                + A.points[2] * B.points[2]
                + A.points[3] * B.points[3]
                + A.points[4] * B.points[4];
            return product;
        }
        public static double GetAngle(vector A,vector B)
        {
            double angle = vector.CrossProduct(A, B) / (A.length * B.length);
            return Math.Acos(angle)*180/Math.PI;
        }
    }
    class Point
    {
        public int[] coordinates = new int[5];
        List<vector> V = new List<vector>();//vectors from this point
        List<double> angles = new List<double>();
        public Point (int[] p)
        {
            for (int i = 0; i < 5; i++)
            {
                coordinates[i] = p[i];
            }
        }
        private vector GetVector(Point p)
        {
            {
                vector v = new vector(this,p);
                return v;
            }
        }
        public void set_vectList(List<Point> Point)
        {
            for (int i = 0; i < Point.Count; i++)
            {
                if (this != Point[i])
                    V.Add(GetVector(Point[i]));
            }
        }
        public void set_angleList()
        {
            for (int i = 0; i < V.Count; i++)
            {
                for (int j = i+1; j < V.Count; j++)
                {
                    angles.Add(vector.GetAngle(V[i], V[j]));
                }
            }
        }
        public bool Isgood()
        {
            foreach (var a in angles)
            {
                if (a < 90)
                    return false;
            }
            return true;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if (n > 11)
            {
                for (int i = 0; i < n; i++)
                {
                    Console.ReadLine();
                }

                Console.WriteLine(0);
            }
            else
            {
                List<Point> lp = new List<Point>();
                int[] count = new int[n];
                int c = 0;
                for (int i = 0; i < n; i++)
                {
                    Point p = new Point(Array.ConvertAll(Console.ReadLine().Split(), int.Parse));
                    lp.Add(p);
                }

                foreach (var point in lp)
                {
                    point.set_vectList(lp);
                    point.set_angleList();
                    if (point.Isgood())
                        count[c]++;
                    c++;
                }
                Console.WriteLine(count.Sum());
                for (int i = 0; i < count.Length; i++)
                {
                    if (count[i] != 0)
                        Console.WriteLine(i + 1);
                }
            }

        }
    }
}


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

namespace codeforces
{
    class Program
    {
        //16:23
        //reading
        static string ReadLine()
        {
            return Console.ReadLine();
        }
        static string[] ReadArray()
        {
            return ReadLine().Split(' ');
        }
        static List<string> ReadList()
        {
            return ReadArray().ToList();
        }
        static List<int> ReadIntList()
        {
            return ReadArray().Select(c => Convert.ToInt32(c)).ToList();
        }
        static List<long> ReadLongList()
        {
            return ReadArray().Select(c => Convert.ToInt64(c)).ToList();
        }
        static List<ulong> ReadULongList()
        {
            return ReadArray().Select(c => Convert.ToUInt64(c)).ToList();
        }
        static int ToInt(string str)
        {
            return Convert.ToInt32(str);
        }
        static long ToInt64(string str)
        {
            return Convert.ToInt64(str);
        }
        static ulong ToUInt64(string str)
        {
            return Convert.ToUInt64(str);
        }

        static void Main(string[] args)
        {
            string str = Convert.ToString(ToInt(ReadLine()), 8);
            int count = 0;
            for (int i = 0; i < str.Length; i++)
                if (str[i] == '1')
                    count++;
            Console.WriteLine(count);
            /*
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            Console.WriteLine(elapsedMs);*/
        }
    }
}


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

public partial class _382C {

    static public void Solve(TextReader cin, TextWriter cout) {
        var scanner = new Scanner(cin);

        int a = scanner.NextInt32();
        int b = scanner.NextInt32();
        int ans = 0, burn = 0;
        while (a > 0) {
            a--;
            burn++;
            ans++;
            if (burn >= b) {
                burn -= b;
                a++;
            }
        }
        cout.WriteLine(ans);
    }

    // PREWRITEN CODE BEGINS FROM HERE

    public static void Main(string[] args) {
#if ONLINE_JUDGE
        Solve(Console.In, Console.Out);
#else
        SampleTest();
#endif

    }

    static void SampleTest() {

        var Inputs = @"
4 2
------------
6 3
".Split(new[] { "------------" }, StringSplitOptions.None).Select(s => s.Trim()).ToArray();

        var Outputs = @"
7
------------
8
".Split(new[] { "------------" }, StringSplitOptions.None).Select(s => s.Trim()).ToArray();

        int caseNo = 1;
        int all = 0, passed = 0;
        foreach (var sample in Inputs.Zip(Outputs, (Input, Output) => new { Input, Output })) {
            var stopWatch = new System.Diagnostics.Stopwatch();
            var writer = new StringWriter();
            stopWatch.Start();
            Solve(new StringReader(sample.Input), writer);
            stopWatch.Stop();
            string time = "";
            if (stopWatch.ElapsedMilliseconds >= 10) {
                time = String.Format("({0} ms)", stopWatch.ElapsedMilliseconds);
            }
            var result = writer.ToString().Trim();
            all++;
            if (result == sample.Output) {
                Console.WriteLine("Sample {0} .... Passed {1}", caseNo++, time);
                passed++;
            } else {
                Console.WriteLine("Sample {0} .... Failed", caseNo++, time);
                Console.WriteLine("Input : ");
                Console.WriteLine("{0}", sample.Input);
                Console.WriteLine("Expected : ");
                Console.WriteLine("{0}", sample.Output);
                Console.WriteLine("Received : ");
                Console.WriteLine("{0}", result);
            }
        }

        Console.WriteLine(" {0} / {1} Passed !!", passed, all);

        Solve(Console.In, Console.Out);
    }

}

public class Scanner {
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private CultureInfo ci = new CultureInfo("en-US");

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        this.Reader = reader;
    }

    public char NextChar() { return Next().Single(); }
    public int NextInt32() { return Int32.Parse(Next(), ci); }
    public long NextInt64() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size) {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt32();
        return array;
    }

    public long[] NextInt64Array(int size) {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextInt64();
        return array;
    }

    public String Next() {
        if (!TokenQueue.Any()) {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext() {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens() {
        while (true) {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var key = "QqRrBbNnPp";
            int[] val = { 9, -9, 5, -5, 3, -3, 3, -3, 1, -1 };
            var map = Enumerate(8, x => sc.Char(8));
            var pt=0;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    for (int k = 0; k < key.Length; k++)
                    {
                        if (map[i][j] == key[k])
                            pt += val[k];
                    }
                }
            }
            if (pt > 0)
                IO.Printer.Out.WriteLine("White");
            else if (pt == 0) IO.Printer.Out.WriteLine("Draw");
            else IO.Printer.Out.WriteLine("Black");

        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b);            return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;
        var dp = new ModInt[2 * N + 1, N + 1];
        dp[0, 0] = 1;
        for (int i = 1; i <= 2 * N; i++)
        {
            for (int j = i % 2; j <= Min(N, 2 * N - i); j += 2)
            {
                if (j > 0) dp[i, j] = dp[i - 1, j - 1];
                if (j < N) dp[i, j] += dp[i - 1, j + 1];
            }
        }

        var S = new ModInt[2 * N + 1];
        for (int i = 0; i < S.Length; i++)
        {
            for (int j = 0; j <= N; j++)
            {
                S[i] += dp[i, j];
            }
        }
        S.Reverse();
       // S.join();

        ModInt ans = 0;
        for (int i = 1; i < S.Length; i += 2)
        {
            ans += S[i];
        }
        WriteLine(ans);

        //for (int i = 0; i < N; i++)
        //{
        //    for (int j = 0; j < (i + 1) * 2; j++)
        //    {
        //        dp[j] += 1;
        //    }
        //    if (i > 0) dp[i * 2] += 1;
        //}
        //dp.join();
        //ModInt ans = 1;
        //foreach (var item in dp)
        //{
        //    ans *= item;
        //}
        //WriteLine(ans);
    }

}

/// <OriginalAuthor>camypaper</OriginalAuthor>
class FenwickTree
{
    readonly int n;
    readonly long[] bit;
    readonly int max = 1;
    public FenwickTree(int size)
    {
        n = size; bit = new long[n + 1];
        while ((max << 1) <= n) max <<= 1;
    }
    /// sum[a, b] 0-indexed
    public long this[int i, int j] { get { i++; j++; return i <= j ? this[j] - this[i - 1] : 0; } }
    /// sum[1, i] 1-indexed
    public long this[int i] { get { long s = 0; for (; i > 0; i -= i & -i) s += bit[i]; return s; } }
    public int LowerBound(long w)
    {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = max; k > 0; k >>= 1)
            if (x + k <= n && bit[x + k] < w)
            {
                w -= bit[x + k];
                x += k;
            }
        return x + 1;
    }
    /// add v to bit[i] 0-indexed
    public void Add(int i, long v)
    {
        i++;
        //if (i == 0) System.Diagnostics.Debug.Fail("BIT is 1 indexed");
        for (; i <= n; i += i & -i) bit[i] += v;
    }
    public long[] Items
    {
        get
        {
            var ret = new long[n + 1];
            for (int i = 0; i < ret.Length; i++)
                ret[i] = this[i, i];
            return ret;
        }
    }
}

class RangeAddFenwickTree
{
    readonly int n;
    FenwickTree a, b;
    public RangeAddFenwickTree(int n)
    {
        this.n = n;
        a = new FenwickTree(n);
        b = new FenwickTree(n);
    }
    /// Add V to[i, j] 0-indexed
    public void Add(int i, int j, long v)
    {
        //a.Add(i, -(i - 1) * v); a.Add(j + 1, j * v);
        //b.Add(i, v); b.Add(j + 1, -v);
        a.Add(i, -i * v); a.Add(j + 1, (j + 1) * v);
        b.Add(i, v); b.Add(j + 1, -v);
    }
    /// Sum [1, i] 1-indexed
    public long this[int i] => a[i] + b[i] * i;
    /// Sum [i, j] 0-indexed
    public long this[int i, int j] { get { i++; j++; return i <= j ? this[j] - this[i - 1] : 0; } }
    public long[] Items
    {
        get
        {
            var ret = new long[n + 1];
            for (int i = 0; i < ret.Length; i++)
                ret[i] = this[i, i];
            return ret;
        }
    }
}

///
/// [0,<see cref="Mod"/>) までの値を取るような数
///
/// <OriginalAuthor>camypaper</OriginalAuthor>
struct ModInt
{
    ///
    /// 剰余を取る値．
    ///
    public const long Mod = (int)1e9 + 7;

    ///
    /// 実際の数値．
    ///
    public long num;
    ///
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    ///
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    ///
    /// このインスタンスの数値を文字列に変換します．
    ///
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    ///
    /// 与えられた 2 つの数値からべき剰余を計算します．
    ///
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    ///
    /// 与えられた 2 つの数値からべき剰余を計算します．
    ///
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k)
    {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    ///
    /// 与えられた数の逆元を計算します．
    ///
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}

class BinomialCoefficient
{
    public ModInt[] fact, ifact;
    public BinomialCoefficient(int n)
    {
        fact = new ModInt[n + 1];
        ifact = new ModInt[n + 1];
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
            fact[i] = fact[i - 1] * i;
        ifact[n] = ModInt.Inverse(fact[n]);
        for (int i = n - 1; i >= 0; i--)
            ifact[i] = ifact[i + 1] * (i + 1);
        ifact[0] = ifact[1];
    }
    public ModInt this[int n, int r]
    {
        get
        {
            if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
            return fact[n] * ifact[n - r] * ifact[r];
        }
    }
    public ModInt RepeatedCombination(int n, int k)
    {
        if (k == 0) return 1;
        return this[n + k - 1, k];
    }
}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


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

namespace MUH_and_Sticks
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
            Array.Sort(a);
            int count = 0;
            if (a[0] == a[1] && a[1] == a[2] && a[2] == a[3])
            {
                if (a[4] == a[5])
                    Console.WriteLine("Elephant");
                else
                    Console.WriteLine("Bear");
            }
            else if (a[2] == a[3] && a[3] == a[4] && a[4] == a[5])
            {
                if ((a[0] == a[1]))
                    Console.WriteLine("Elephant");
                else
                    Console.WriteLine("Bear");
            }
            else
            {

                if(a[0] == a[1] && a[1] == a[2] && a[2] == a[3]|| a[1] == a[2] && a[2] == a[3] && a[3] == a[4]|| a[2] == a[3] && a[3] == a[4] && a[4] == a[5])
                    Console.WriteLine("Bear");
                else
                    Console.WriteLine("Alien");
            }
            Console.ReadLine();
        }
    }
}


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

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            int n = ReadInt();
            long w = ReadLong();
            var segments = new Segment[n];
            var starts = new List<PP>();
            var ends = new List<PP>();
            for (int i = 0; i < n; i++)
            {
                long x = ReadLong();
                long v = -ReadLong();
                bool swap = false;
                if (x < 0)
                {
                    x = -x;
                    v = -v;
                    swap = true;
                }
                var start = new PP(x, v + w);
                var end = new PP(x, v - w);
                if (swap)
                {
                    PP tmp = start;
                    start = end;
                    end = tmp;
                }
                segments[i] = new Segment(start, end);

                starts.Add(start);
                ends.Add(end);
            }

            starts = starts.Shuffle().ToList();
            starts.Sort(Comparison);

            for (int i = 0; i < starts.Count; i++)
            {
                starts[i].Segment.End.X = i;
            }

            ends = ends.Shuffle().ToList();
            ends.Sort(Comparison);

            var p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = ends[i].X;
            }

            long ans = Permutation.InversionsCount(p);
            Writer.WriteLine(ans);
        }

        private static int Comparison(PP a, PP b)
        {
            long d = -(a.A * b.B - a.B * b.A);
            if (d != 0)
            {
                return d > 0 ? 1 : -1;
            }
            if (a.X != b.X)
            {
                return b.X - a.X;
            }
            if (a != a.Segment.End)
            {
                return Comparison(b.Segment.End, a.Segment.End);
            }
            return 0;
        }

        public static class Permutation
        {
            public static long InversionsCount(int[] permutation)
            {
                int[] a = permutation.ToArray();
                int[] b = permutation.ToArray();
                return InversionsCountInternal(a, 0, permutation.Length, b);
            }

            private static long InversionsCountInternal(int[] a, int lo, int hi, int[] b)
            {
                if (hi - lo < 2)
                    return 0;

                int mid = (lo + hi) / 2;

                return InversionsCountInternal(b, lo, mid, a) + InversionsCountInternal(b, mid, hi, a) + Merge(a, lo, mid, hi, b);
            }

            private static long Merge(int[] a, int lo, int mid, int hi, int[] b)
            {
                int i = lo;
                int j = mid;
                long result = 0;
                for (int k = lo; k < hi; k++)
                {
                    if (i < mid && (j >= hi || a[i] <= a[j]))
                    {
                        b[k] = a[i];
                        i++;
                    }
                    else
                    {
                        b[k] = a[j];
                        j++;
                        result += (mid - i);
                    }
                }
                return result;
            }
        }

        public class PP
        {
            public PP(long a, long b)
            {
                A = a;
                B = b;
                X = 0;
            }

            public long A;

            public long B;

            public int X;

            public Segment Segment;
        }

        public class Segment
        {
            public Segment(PP start, PP end)
            {
                Start = start;
                End = end;
                OnStart = 0;
                start.Segment = this;
                end.Segment = this;
            }

            public PP Start;

            public PP End;

            public long OnStart;
        }

        public static void Solve()
        {
            // int T = ReadInt();
            // for (int i = 0; i < T; i++)
            // {
            //     Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            // }
        }

        public class Point
        {
            public Point(int x, int y)
            {
                X = x;
                Y = y;
            }

            public int X;

            public int Y;

            public double Length { get { return Math.Sqrt(X * X + Y * Y); } }

            protected bool Equals(Point other)
            {
                return X == other.X && Y == other.Y;
            }

            public override bool Equals(object obj)
            {
                if (ReferenceEquals(null, obj))
                {
                    return false;
                }
                if (ReferenceEquals(this, obj))
                {
                    return true;
                }
                /*if (obj.GetType() != this.GetType())
                {
                    return false;
                }*/
                return Equals((Point) obj);
            }

            public override int GetHashCode()
            {
                unchecked
                {
                    return (X * 397) ^ Y;
                }
            }

            public int Dist2(Point p)
            {
                return (p.X - X) * (p.X - X) + (p.Y - Y) * (p.Y - Y);
            }

            public static Point operator +(Point a, Point b)
            {
                return new Point(a.X + b.X, a.Y + b.Y);
            }

            public static Point operator -(Point a, Point b)
            {
                return new Point(a.X - b.X, a.Y - b.Y);
            }
        }

        public static class Standard
        {
            public static long Power(long x, long p, long mod)
            {
                long result = 1;
                while (p > 0)
                {
                    if ((p & 1) == 0)
                    {
                        x = (x * x) % mod;
                        p >>= 1;
                    }
                    else
                    {
                        result = (result * x) % mod;
                        p--;
                    }
                }
                return result;
            }

            public static long Gcd(long a, long b)
            {
                return b == 0 ? a : Gcd(b, a % b);
            }

            public static List<int> GetPrimes(int n)
            {
                bool[] isPrime = Enumerable.Repeat(true, n + 1).ToArray();
                isPrime[0] = false;
                isPrime[1] = false;
                for (int i = 2; i <= n; i++)
                {
                    if (isPrime[i])
                    {
                        for (int j = i + i; j <= n; j += i)
                        {
                            isPrime[j] = false;
                        }
                    }
                }
                List<int> primes = new List<int>();
                for (int i = 0; i <= n; i++)
                {
                    if (isPrime[i])
                    {
                        primes.Add(i);
                    }
                }
                return primes;
            }
        }

        public static void Main()
        {
            //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            //Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            Solve();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        private static Queue<string> CurrentLineTokens = new Queue<string>();

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

        public static string ReadToken()
        {
            while (CurrentLineTokens.Count == 0)
                CurrentLineTokens = new Queue<string>(ReadAndSplitLine());
            return CurrentLineTokens.Dequeue();
        }

        public static string ReadLine()
        {
            return Reader.ReadLine();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadIntArray();
            return matrix;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++)
                lines[i] = Reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            Writer.WriteLine(string.Join(" ", array));//
        }

        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public void Solve(Scanner sc)
    {
        string S = sc.Str, T = sc.Str;
        var dp = Create(S.Length + 1, () => Create(T.Length+1, () => Create(201, () => int.MaxValue / 4)));
        dp[0][0][0] = 0;

        for (int i = 0; i <= S.Length; i++)
        {
            for (int j = 0; j <= T.Length; j++)
            {
                for (int k = 0; k < 200; k++)
                {
                    chmin(ref dp[i][j][k + 1], dp[i][j][k] + 1);
                }
                for (int k = 199; k >= 0; k--)
                {
                    chmin(ref dp[i][j][k], dp[i][j][k + 1] + 1);
                }
                for (int k = 0; k < 201; k++)
                {
                    if (i<S.Length&&j<T.Length&&S[i] == T[j])
                    {
                        int c = k;
                        if (S[i] == '(') c++;
                        else c--;
                        if (0 <= c && c < 201)
                            chmin(ref dp[i + 1][j + 1][c], dp[i][j][k] + 1);
                    }
                    if(i<S.Length)
                    {
                        int c = k;
                        if (S[i] == '(') c++;
                        else c--;
                        if (0 <= c && c < 201)
                            chmin(ref dp[i + 1][j][c], dp[i][j][k] + 1);
                    }
                    if(j<T.Length)
                    {
                        int c = k;
                        if (T[j] == '(') c++;
                        else c--;
                        if (0 <= c && c < 201)
                            chmin(ref dp[i][j + 1][c], dp[i][j][k] + 1);
                    }
                }
            }
        }
        var res = new List<char>();
        int s = S.Length, t = T.Length, l = 0;
        while (dp[s][t][l] != 0)
        {
            for(int j = -1; j < 2; j += 2)
            {
                int n = l + j;
                if (0 <= n && n < 201 && dp[s][t][n] + 1 == dp[s][t][l])
                {
                    l = n;
                    if (j == -1) res.Add('(');
                    else res.Add(')');
                    goto END;
                }
            }
            if (s>0&&t>0&&S[s - 1] == T[t - 1])
            {
                int n = l;
                if (S[s - 1] == '(') n--;
                else n++;
                if (0 <= n && n < 201 && dp[s - 1][t - 1][n] + 1 == dp[s][t][l])
                {
                    res.Add(S[s - 1]);
                    s--;t--;l = n;goto END;
                }
            }
            if (s > 0)
            {
                int n = l;
                if (S[s - 1] == '(') n--;
                else n++;
                if (0 <= n && n < 201 && dp[s - 1][t][n] + 1 == dp[s][t][l])
                {
                    res.Add(S[s - 1]);
                    s--; l = n; goto END;
                }
            }
            if (t > 0)
            {
                int n = l;
                if (T[t - 1] == '(') n--;
                else n++;
                if (0 <= n && n < 201 && dp[s][t-1][n] + 1 == dp[s][t][l])
                {
                    res.Add(T[t - 1]);
                    t--; l = n; goto END;
                }
            }
        END:;
        }
        res.Reverse();
        Console.WriteLine(new string(res.ToArray()));
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


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

class Program
{
    const bool TEST_MODE = false;

    static void Main()
    {
        if (TEST_MODE)
        {
            string[] readText = File.ReadAllLines("..\\..\\TextFile1.txt");

            var testCases = new Dictionary<List<string>, string>();
            var lastKeyword = "";
            var current = new List<string>();
            foreach (string s in readText)
            {
                if(s == "Input")
                {
                    current = new List<string>();
                    lastKeyword = s;
                    continue;
                }
                if (s == "Copy")
                    continue;
                if (s == "Output")
                {
                    lastKeyword = s;
                    continue;
                }

                if (lastKeyword == "Input")
                    current.Add(s);
                if (lastKeyword == "Output")
                    testCases.Add(current,s);

            }

            foreach(var testCase in testCases)
            {
                var result = ProblemWrapper.Solve(testCase.Key.ToArray(), testCase.Value);
                if (result == testCase.Value)
                    Console.ForegroundColor = ConsoleColor.Green;
                else
                    Console.ForegroundColor = ConsoleColor.Red;

                Console.Write("input: ");
                foreach (var input in testCase.Key)
                    Console.Write(input + " // ");
                Console.Write("\noutput: ");
                Console.WriteLine(testCase.Value);

                Console.Write("Actual: ");
                Console.WriteLine(result);

                Console.ResetColor();
            }
        }
        else
            ProblemWrapper.Solve();

        Console.ReadLine();
    }
}

class ProblemWrapper
{
    public static void Solve()
    {
        string[] input = new string[2];
        input[0] = Console.ReadLine();
        input[1] = Console.ReadLine();

        var a = ReadString(input[0]);
        var b = ReadString(input[1]);

        Console.WriteLine (Algo(a, b));
    }

    public static string Solve(string[] input, string output)
    {
        var a = ReadString(input[0]);
        var b = ReadString(input[1]);

        return (Algo(a, b));
    }

    public static string Algo(string a, string b)
    {
        int answer = 0;

        //**
        {
            var row1 = a.ToCharArray();
            var row2 = b.ToCharArray();

            var n = row1.Length;
            if (n < 2)
                return "0";

            for (var i = 0; i < n; i++)
            {
                if (row1[i] == '0')
                {
                    if (i != 0 && row2[i - 1] == '0' && row2[i] == '0')
                    {
                        row1[i] = 'X'; row2[i] = 'X'; row2[i - 1] = 'X';
                        answer++;
                    }
                    else if (i != 0 && row2[i] == '0' && row1[i - 1] == '0')
                    {
                        row1[i] = 'X'; row2[i] = 'X'; row1[i - 1] = 'X';
                        answer++;
                    }
                    else if (i != n - 1 && row2[i] == '0' && row2[i + 1] == '0')
                    {
                        row1[i] = 'X'; row2[i] = 'X'; row2[i + 1] = 'X';
                        answer++;
                    }
                    else if (i != n - 1 && row2[i] == '0' && row1[i + 1] == '0')
                    {
                        row1[i] = 'X'; row2[i] = 'X'; row1[i + 1] = 'X';
                        answer++;
                    }
                }

            }
        }
        //**

        return Convert.ToString(answer);
    }

    static String   ReadString(string input)    { return input; }
    static String[] ReadStringArr(string input) { return input.Split(' '); }
    static int      ReadInt(string input)       { return int.Parse(input); }
    static long     ReadLong(string input)      { return long.Parse(input); }
    static double   ReadDouble(string input)    { return double.Parse(input); }
    static int[]    ReadIntArr(string input)    { return Array.ConvertAll(input.Split(' '), e =>    int.Parse(e)); }
    static long[]   ReadLongArr(string input)   { return Array.ConvertAll(input.Split(' '), e =>   long.Parse(e)); }
    static double[] ReadDoubleArr(string input) { return Array.ConvertAll(input.Split(' '), e => double.Parse(e)); }
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Numerics;

namespace ConsoleApplication1
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;
        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }
        class Cut
        {
            public int a;
            public int b;
            public int line;
        }
        object Get()
        {
            checked
            {
                var a = ReadInts();
                var d = new[] { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
                var result = 0;
                for (int i = a[0]; i <= a[1]; i++)
                {
                    var s = i.ToString();
                    foreach (var c in s)
                        result += d[Int32.Parse(c.ToString())];
                }
                return result;
            }
        }

        object Get2()
        {
            FileName = "";
            checked
            {
                var m = ReadInt();
                var p = ReadLongs();
                var arr = p.GroupBy(x => x).Select(g => new { g.Key, Count = g.Count() }).ToArray();
                BigInteger divs = 1;
                long result = 1;
                foreach (var a in arr)
                {
                    var pi = a.Key;
                    var curr = pi;
                    var olddivs = divs;
                    var oldres = result;
                    for (int i = 0; i < a.Count; i++)
			        {
                        result = (result * oldres % commonMod) * FastPow(curr, olddivs, commonMod) % commonMod;
                        curr = curr*pi % commonMod;
                        divs = divs + olddivs;
			        }
                }
                return result;
            }
        }

        public long FastPow(long x, BigInteger pow, long mod)
        {
            if (pow == 0)
                return 1;
            if ((pow & 1) == 0)
                return FastPow(x * x % mod, pow / 2, mod);
            return x * FastPow(x, pow - 1, mod) % mod;
        }

        //object Get3()
        //{
        //    FileName = "";
        //    checked
        //    {
        //        var n = ReadInt();
        //        var hor = new List<Cut>();
        //        var ver = new List<Cut>();
        //        for (int i = 0; i < n; i++)
        //        {
        //            var a = ReadInts();
        //            if (a[0] == a[2])
        //                ver.Add(new Cut() { a = Math.Min(a[1], a[3]), b = Math.Max(a[1], a[3]), line = a[0] });
        //            else
        //                hor.Add(new Cut() { a = Math.Min(a[0], a[2]), b = Math.Max(a[0], a[2]), line = a[1] });
        //        }
        //        ver = Merge(ver);
        //        hor = Merge(hor);

        //    }
        //}

        List<Cut> Merge(List<Cut> l)
        {
            var a = l.OrderBy(x => x.line).ThenBy(x => x.a).ToArray();
            Cut previous = null;
            var result = new List<Cut>();
            for (int i = 0; i < a.Length; i++)
                if (previous == null)
                    previous = a[i];
                else
                    if (previous.line == a[i].line && previous.b >= a[i].a)
                        previous.b = Math.Max(previous.b, a[i].b);
                    else
                    {
                        result.Add(previous);
                        previous = a[i];
                    }
            if (previous != null)
                result.Add(previous);
            return result;
        }

        object Get3()
        {
            FileName = "";
            checked
            {
                var n = ReadInt();
                var beacons = new List<Tuple<int, int>>();
                for (int i = 0; i < n; i++)
                {
                    var inp = ReadInts();
                    beacons.Add(Tuple.Create(inp[0], inp[1]));
                }
                beacons = beacons.OrderBy(x => x.Item1).ToList();
                var dp = new int[n];
                for (int i = 0; i < n; i++)
                {
                    var j = LowerBound(beacons, beacons[i].Item1 - beacons[i].Item2);
                    dp[i] = j == -1
                        ? 1
                        : dp[j] + 1;
                }
                return n - dp.Max();
            }
        }

        private int LowerBound(List<Tuple<int, int>> beacons, int v, int left, int right)
        {
            if (left == right)
                if (beacons[left].Item1 < v)
                    return left;
                else
                    return -1;
            if (right - left == 1)
                if (beacons[right].Item1 < v)
                    return right;
                else if (beacons[left].Item1 < v)
                    return left;
                else
                    return -1;
            var half = (left + right) / 2;
            if (v <= beacons[half].Item1)
                return LowerBound(beacons, v, left, half);
            else
                return LowerBound(beacons, v, half, right);
        }

        private int LowerBound(List<Tuple<int, int>> beacons, int v)
        {
            return LowerBound(beacons, v, 0, beacons.Count - 1);
        }

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

        IEnumerable<List<string>> GetS(List<string> ss)
        {
            if (ss.Count == 0)
                yield return (new List<string>());
            else
                foreach (var s in ss)
                {
                    var next = new List<string>(ss);
                    next.Remove(s);
                    foreach (var item in GetS(next))
                    {
                        item.Add(s);
                        yield return item;
                    }
                }
        }
    }
    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (string.IsNullOrEmpty(FileName))
                return Console.ReadLine();
            if (f == null)
                f = new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName + ".in");
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return Convert.ToInt32(Read());
        }
        protected int[] ReadInts()
        {
            return Read().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            return Read().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();
        }

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

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

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

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

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


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    private const int MAX = 200000;

    bool Intersect(int l1, int r1, int l2, int r2)
    {
        return !(r2 < l1 || l2 > r1);
    }

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

        var left = new int[MAX];
        var right = new int[MAX];
        int c = 1;
        for (int i = 1; i < MAX; i++)
        {
            left[i] = right[i] = c;
            if ((i & i - 1) == 0)
            {
                right[i]++;
                c++;
            }
            c++;
        }

        var idx = new Dictionary<int, int>();
        var q = Init<List<Tuple<int, int, int>>>(n);
        for (int m = ReadInt(); m > 0; m--)
        {
            if (ReadInt() == 1)
            {
                int t = ReadInt() - 1;
                int l = ReadInt();
                int r = ReadInt();
                int x = ReadInt();
                if (!idx.ContainsKey(x))
                    idx[x] = idx.Count;
                q[t].Add(Tuple.Create(l, r, idx[x]));
            }
            else
            {
                int t = ReadInt() - 1;
                int v = ReadInt();
                int l = v, r = v;
                var f = new bool[idx.Count];
                for (; t < n; t++, l = left[l], r = right[r])
                    foreach (var qq in q[t])
                        if (Intersect(qq.Item1, qq.Item2, l, r))
                            f[qq.Item3] = true;
                int ans = 0;
                for (int i = 0; i < idx.Count; i++)
                    if (f[i])
                        ans++;
                Write(ans);
            }
        }
    }

    #region Main

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

    #endregion

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


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

namespace vkcup
{
	class Program
	{
		public static int n, m, h, w;

		public static int x1, x2, y1, y2;

		public static int[] arr;
		private static String s1;
		private static String s2;
		static void Main(string[] args)
		{
			ParseAll(true);
			Solve();
		}

		static void Solve()
		{
			if ((x2 <= x1 && y2 <= y1) ||
				(y2 < y1 && x2 - x1 < y1) ||
				(x2 < x1 && y2 - y1 < x1))
			{
				Console.WriteLine("Vasiliy");
			}
			else
			{
				Console.WriteLine("Polycarp");
			}
			return;
		}

		static void ParseAll(bool console)
		{
			if (console)
			{
				ParseFirstLine(Console.ReadLine());
				//ParseArray(2);
			}
		}

		static void ParseFirstLine(String line)
		{
			int[] arr = line.Split(' ').Select(int.Parse).ToArray();
			x1 = arr[0];
			y1 = arr[1];
			x2 = arr[2];
			y2 = arr[3];
		}

		static void ParseSecondLine(String line)
		{
			int[] array = line.Split(' ').Select(int.Parse).ToArray();

		}

		static void ParseThirdLine(String line)
		{
			int[] array = line.Split(' ').Select(int.Parse).ToArray();

		}

		static void ParseArray(int count)
		{
			s1 = Console.ReadLine();
			s2 = Console.ReadLine();

		}

	}
}


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

namespace first
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c,aMod,bMod,cMod;
            string str = Console.ReadLine();
            a=int.Parse(str);
            str=str.Replace("0", "");
            aMod = int.Parse(str);
            str = Console.ReadLine();
            b = int.Parse(str);
            str=str.Replace("0", "");
            bMod = int.Parse(str);
            c = a + b;
            cMod = int.Parse(c.ToString().Replace("0", ""));
            if ((aMod + bMod) == cMod)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

namespace Problem_1C
{
    struct Point
    {
        public double X, Y;

        public Point(double X, double Y)
        {
            this.X = X;
            this.Y = Y;
        }
    }

    struct Line
    {
        public bool IsVertical { get { return double.IsPositiveInfinity(slope); } }
        public double slope, yIntercept, xIntercept;

        public Line(Point a, Point b)
        {
            if (a.X == b.X)
            {
                this.slope = double.PositiveInfinity;
                this.yIntercept = double.NaN;
                this.xIntercept = a.X;
            }
            else
            {
                var rise = b.Y - a.Y;
                var run = b.X - a.X;

                this.slope = rise / run;
                this.yIntercept = b.Y - this.slope * b.X;
                this.xIntercept = Math.Abs(rise) < 0.00001 ? double.NaN : -(b.Y - this.slope * b.X) / (rise / run);
            }
        }

        public Line(double slope, double yIntercept, Point p)
        {
            this.slope = slope;
            this.yIntercept = yIntercept;
            this.xIntercept = double.IsPositiveInfinity(slope) ? p.X : -yIntercept / slope;
        }

        public Line PerpendicularLineAt(Point p)
        {
            if (IsVertical)
                return new Line(0, -p.Y, p);
            else if (Math.Abs(this.slope) < 0.00001)
                return new Line(double.PositiveInfinity, double.NaN, p);
            else
                return new Line(-1 / this.slope, p.Y + 1 / this.slope * p.X, p);
        }

        public Point IntersectionWith(Line l)
        {
            if (l.IsVertical)
                return new Point(l.xIntercept, this.slope * l.xIntercept + this.yIntercept);
            else if (this.IsVertical)
                return new Point(this.xIntercept, l.slope * this.xIntercept + l.yIntercept);
            else
            {
                double x = (l.yIntercept - this.yIntercept) / (this.slope - l.slope);
                return new Point(x, this.slope * x + this.yIntercept);
            }
        }
    }

    class Program
    {
        static Point GetPoint()
        {
            var line = Console.ReadLine().Split(' ');
            return new Point(double.Parse(line[0], System.Globalization.CultureInfo.InvariantCulture), double.Parse(line[1], System.Globalization.CultureInfo.InvariantCulture));
        }

        static Point Midpoint(Point a, Point b)
        {
            return new Point((b.X + a.X) / 2, (b.Y + a.Y) / 2);
        }

        static double Distance(Point a, Point b)
        {
            return Math.Sqrt(Math.Pow(b.X - a.X, 2) + Math.Pow(b.Y - a.Y, 2));
        }

        static void Main(string[] args)
        {
            var p1 = GetPoint();
            var p2 = GetPoint();
            var p3 = GetPoint();

            var l1 = new Line(p1, p2);
            var l2 = new Line(p2, p3);
            var l3 = new Line(p3, p1);

            var la = l1.IsVertical ? l2 : l1;
            var lb = l3.IsVertical ? l2 : l3;
            var ma = l1.IsVertical ? Midpoint(p2, p3) : Midpoint(p1, p2);
            var mb = l3.IsVertical ? Midpoint(p2, p3) : Midpoint(p3, p1);
            var pba = la.PerpendicularLineAt(ma);
            var pbb = lb.PerpendicularLineAt(mb);
            var o = pba.IntersectionWith(pbb);
            var r = Distance(o, p1);

            for (int i = 3; i <= 100; i++)
            {
                double theta = Math.Abs(p1.X - o.X) < 0.00001 ? Math.PI / 2 : Math.Atan((p1.Y - o.Y) / (p1.X - o.X));
                if (p1.X - o.X < 0) theta += Math.PI;
                double addTheta = 2 * Math.PI / i;
                bool p2Matched = false, p3Matched = false;
                for (int j = 1; j < i; j++)
                {
                    theta += addTheta;
                    double y = r * Math.Sin(theta) + o.Y;
                    double x = r * Math.Cos(theta) + o.X;
                    if (Math.Abs(p2.X - x) < 0.00001 && Math.Abs(p2.Y - y) < 0.00001) p2Matched = true;
                    if (Math.Abs(p3.X - x) < 0.00001 && Math.Abs(p3.Y - y) < 0.00001) p3Matched = true;
                }

                if (p2Matched && p3Matched)
                {
                    var area = i * r * r / 2 * Math.Sin(2 * Math.PI / i);
                    Console.WriteLine(area.ToString("0.000000", System.Globalization.CultureInfo.InvariantCulture));
                    break;
                }
            }

        }
    }
}


using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main()
        {
            byte[] input = Console.ReadLine().Split(' ').Select(num => Convert.ToByte(num)).ToArray();
            Console.WriteLine((int)(input[0] * input[1] / 2));
        }
    }
}


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

namespace codeforces
{
    class Program
    {

        static void Main(string[] args)
        {
            // Console.SetIn(new StreamReader("text.txt"));
            int[] count = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = count[0], y = count[1], z = count[2];
            string rez = "";
            if (x == y && z == 0)
                rez = "0";
            else if (x > y && y + z < x)
                rez = "+";
            else if (x < y && x+ z < y)
                rez = "-";
            else
                rez = "?";

            Console.WriteLine(rez);
        }
    }
}


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

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

			//string input3 = Console.ReadLine();
			//string input4 = Console.ReadLine();

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

			long n = inputs1[0];
			long k = inputs1[1];

			if (k < 3)
			{
				Console.WriteLine(0);
				return;
			}

			long count = 0;
			long min = 0, max = 0;

			if (k <= n)
			{
				min = 1;
				max = k - min;
			}
			else
			{
				min = k - n;
				if (min > n)
				{
					Console.WriteLine(0);
					return;
				}

				max = n;
			}

			Console.WriteLine((Math.Max(min, max) - Math.Min(min, max) + 1) / 2);
		}

		public class Team
		{
			public string Name { get; set; }

			public int Points { get; set; }

			public int GoalsFor { get; set; }

			public int GoalsAgainst { get; set; }
		}

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