using System;
using System.Collections.Generic;
using System.Linq;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using Number = System.Int64;
using System.Numerics;
using static System.Math;
namespace Program {
    public class Solver {
        Random rnd = new Random ();
        public void Solve () {

            var k = rl;
            var n = rl;
            var s = rl;
            var p = rl;

            var X = (n + s - 1) / s;
            var Y = (X * k + p - 1) / p;
            Console.WriteLine (Y);
        }
        const long INF = 1L << 60;
        //static int[] dx = { -1, 0, 1, 0 };
        //static int[] dy = { 0, 1, 0, -1 };

        int ri { get { return sc.Integer (); } }
        long rl { get { return sc.Long (); } }
        double rd { get { return sc.Double (); } }
        string rs { get { return sc.Scan (); } }
        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;
        }
        static public void Swap<T> (ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}
#region main
static class Ex {
    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 void Main () {
        Console.SetOut (new Program.IO.Printer (Console.OpenStandardOutput ()) { AutoFlush = false });
        var solver = new Program.Solver ();
        try {
            solver.Solve ();
            Console.Out.Flush ();
        } catch { }
    }
}
#endregion
#region Ex


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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int ans=0;
            string[] tokens = Console.ReadLine().Split();
            int k = int.Parse(tokens[0]);
            int n = int.Parse(tokens[1]);
            int s = int.Parse(tokens[2]);
            int p = int.Parse(tokens[3]);
            ans=((k*(n+s-1)/s)+p-1)/p;
            Console.WriteLine(ans);
        }
    }
}


class MainClass
    {
        public static void Main(string[] args)
        {
            var fl = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var sl = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int n = fl[0] - 1;
            int k = fl[1];
            int x = fl[2];

            int sum = 0;
            for (var i = n; i > -1; i--){
                if (n - i < k){
                    continue;
                }

                sum += sl[i];
            }

            Console.WriteLine(sum + k * x);
        }
    }


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{C22E8B66-0EF5-43B8-86DC-85B1FB630485}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>A.Keyboard</RootNamespace>
    <AssemblyName>A.Keyboard</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] arr = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                String line = Console.ReadLine();
                String[] ps = line.Split(' ');
                for (int j = 0; j < 3; i++)
                {
                    arr[i, j] = int.Parse(ps[i]);
                }
            }

                arr[0, 0] = ((arr[1, 0] + arr[1, 2]) - (arr[0, 1] + arr[0, 2]) + (arr[2, 0] + arr[2, 1])) / 2;
                 arr[1, 1] = (arr[2, 0] + arr[2, 1])-arr[0, 0] ;
                 arr[2, 2] = (arr[0,0] + arr[0,1]) - arr[1, 2];
                 for (int i = 0; i < 3; i++)
                 {

                     for (int j = 0; j < 3; i++)
                     {
                         Console.Write(arr[i, j] + " ");
                     }
                     Console.WriteLine();
                 }
        }
    }
}


using System; using System.Linq;

class P {
  static void Main() {
    var m = Enumerable.Range(0,3).Select(i =>
              Console.ReadLine().Split(' ').Select(int.Parse).ToArray())
            .ToArray();
    m[0][0] = m[1][1] = m[2][2] = 1;
    var r = new int[3];
    var c = new int[3];
    for (var y=0;y<3;y++)for (var x=0;x<3;x++){r[y]+=m[y][x];c[x]+=m[y][x]; }

    var d1 = m[0][0]+m[1][1]+m[2][2];
    var d2 = m[0][2]+m[1][1]+m[2][0];

    var max = new [] { r[0], r[1], r[2],
                       c[0], c[1], c[2],
                       d1, d2 }.Max();
    var k = 0;
    for (var i = 0; k < 3 ; i = (i+1)%3) {
      var c2 = (new [] { r[i], c[i], i==1?d2:int.MaxValue}).Min();
      var diff = max - c2;
      k = diff==0? k + 1 : 0;
      m[i][i]+=diff; r[i]+=diff; c[i]+=diff; d1 += diff; if (i==2)d2+=diff;
      max = Math.Max(max, r[i]);
      max = Math.Max(max, c[i]);
      max = Math.Max(max, d1);
      max = Math.Max(max, d2);
    }
    for (var y = 0; y < 3 ; y++) Console.WriteLine(string.Join(" ", m[y]));
  }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        var ar = new int[9];
        for (int i = 0; i < 9; i++)
        {
            ar[i] = Next();
        }
        var diag = ar.Sum() / 2;
        for (int i = 1; i <= diag - 2; i++)
        {
            for (int j = 1; j <= diag - 2; j++)
            {
                for (int k = 1; k <= diag - 2; k++)
                {
                    if ((ar[0] = i) + ar[1] + ar[2] == (ar[4] = j) + ar[3] + ar[5] && j + ar[3] + ar[5] == (ar[8] = k) + ar[6] + ar[7] && ar[0] + ar[4] + ar[8] == ar[2] + ar[4] + ar[6])
                    {
                        WriteArray(ar.Take(3));
                        WriteArray(ar.Skip(3).Take(3));
                        WriteArray(ar.Skip(6));
                        break;
                    }
                }
            }
        }
        reader.Close();
        writer.Close();
    }
    #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<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }
    private static int Next()
    {
        int c;
        int res = 0;
        do
        {
            c = reader.Read();
            if (c == -1)
                return res;
        } while (c != '-' && (c < '0' || c > '9'));
        int sign = 1;
        if (c == '-')
        {
            sign = -1;
            c = reader.Read();
        }
        res = c - '0';
        while (true)
        {
            c = reader.Read();
            if (c < '0' || c > '9')
                return res * sign;
            res *= 10;
            res += c - '0';
        }
    }
    #endregion
}


using System;
using System.Collections.Generic;

namespace InsomniaCure
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = Convert.ToInt32(Console.ReadLine());
            int l = Convert.ToInt32(Console.ReadLine());
            int m = Convert.ToInt32(Console.ReadLine());
            int n = Convert.ToInt32(Console.ReadLine());
            int d = Convert.ToInt32(Console.ReadLine());

            int ogk = k;
            int ogl = l;
            int ogm = m;
            int ogn = n;

            int[] dragons = new int[d];

            for(int i = 0; i < dragons.Length; i++)
            {
                dragons[i] = i + 1;
            }

            List<int> hurt_dragons = new List<int>();

            for(int i = 0; i < dragons.Length; i++)
            {
                if(i == k - 1)
                {
                    bool isHurt = false;
                    for(int j = 0; j < hurt_dragons.Count; j++)
                    {
                        if (hurt_dragons[j] == dragons[i])
                        {
                            isHurt = true;
                        }
                    }
                    if (!isHurt)
                    {
                        hurt_dragons.Add(dragons[i]);
                    }

                    k += ogk;
                }

                if (i == l - 1)
                {
                    bool isHurt = false;
                    for (int j = 0; j < hurt_dragons.Count; j++)
                    {
                        if (hurt_dragons[j] == dragons[i])
                        {
                            isHurt = true;
                        }
                    }
                    if (!isHurt)
                    {
                        hurt_dragons.Add(dragons[i]);
                    }

                    l += ogl;
                }

                if (i == m - 1)
                {
                    bool isHurt = false;
                    for (int j = 0; j < hurt_dragons.Count; j++)
                    {
                        if (hurt_dragons[j] == dragons[i])
                        {
                            isHurt = true;
                        }
                    }
                    if (!isHurt)
                    {
                        hurt_dragons.Add(dragons[i]);
                    }

                    m += ogm;
                }

                if (i == n - 1)
                {
                    bool isHurt = false;
                    for (int j = 0; j < hurt_dragons.Count; j++)
                    {
                        if (hurt_dragons[j] == dragons[i])
                        {
                            isHurt = true;
                        }
                    }
                    if (!isHurt)
                    {
                        hurt_dragons.Add(dragons[i]);
                    }

                    n += ogn;
                }
            }

            Console.WriteLine(hurt_dragons.Count);

        }
    }
}


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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            // the inputs
            int k = int.Parse(Console.ReadLine());
            int l = int.Parse(Console.ReadLine());
            int m = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());

            var vDamaged = new bool[d];
            for (int i = 0; i < k - 1; ++i)
            {
                vDamaged[i] = false;
            }

            for (int i = k - 1; i < d; i += k)
            {
                vDamaged[i] = true;
            }

            for (int i = l - 1; i < d; i += l)
            {
                vDamaged[i] = true;
            }

            for (int i = m - 1; i < d; i += m)
            {
                vDamaged[i] = true;
            }

            for (int i = n - 1; i < d; i += n)
            {
                vDamaged[i] = true;
            }

            int cnt = 0;
            for (int i = 0; i < vDamaged.Length; ++i)
            {
                cnt += vDamaged[i] ? 1 : 0;
            }

            // display results
            Console.WriteLine(cnt);
        }
    }
}


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

namespace testSH
{

    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int key = int.Parse(s[0]);
            if (string.Compare(s[3], "week") == 0)
            {
                if ((key < 5) || (key == 7))
                    Console.WriteLine(52);
                else
                    Console.WriteLine(53);
            }
            else
            {
                if (key < 30)
                    Console.WriteLine(12);
                else
                    if (key == 30)
                        Console.WriteLine(11);
                    else
                        Console.WriteLine(7);
            }
        }
    }
}


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

namespace er
{
    class Program
    {

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

            int n = int.Parse(s[0]);
            int ans = 0;
            if(s[2]=="week")
            {
                ans = 52;
            }
            else
            {
                if (n == 31) ans = 7;
                else if (n == 30) ans = 11;
                else ans = 12;
            }

            Console.WriteLine(ans);

        }
    }
    }


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

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

        }
    }
}

        }
    }
}


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


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

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

class Sol{
	public void Solve(){

		for(int i=0;i<4;i++){
			if(Inside(A[2*i], A[2*i+1], B)){
				Console.WriteLine("YES");
				return;
			}
			if(Inside(B[2*i], B[2*i+1], A)){
				Console.WriteLine("YES");
				return;
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(OnLine(A[2*i], A[2*i+1], B[2*j], B[2*j+1], B[(2*j+2)%8], B[(2*j+3)%8])){
					Console.WriteLine("YES");
					return;
				}
				if(OnLine(B[2*i], B[2*i+1], A[2*j], A[2*j+1], A[(2*j+2)%8], A[(2*j+3)%8])){
					Console.WriteLine("YES");
					return;
				}
			}
		}
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(Intersects(A[2*j], A[2*j+1], A[(2*j+2)%8], A[(2*j+3)%8], B[2*j], B[2*j+1], B[(2*j+2)%8], B[(2*j+3)%8])){
					Console.WriteLine("YES");
					return;
				}
			}
		}
		Console.WriteLine("NO");

	}

	bool Inside(int x, int y, int[] rect){
		var h = new HashSet<int>();
		for(int i=0;i<4;i++){
			var d = det(rect[2*i] - x, rect[2*i+1] - y, rect[(2*i+2)%8] - x, rect[(2*i+3)%8] - y);
			if(d == 0) return false;
			d = d > 0 ? 1 : -1;
			h.Add(d);
		}
		return h.Count == 1;
	}
	bool OnLine(int x, int y, int x1, int y1, int x2, int y2){
		if(x == x1 && y == y1) return true;
		if(x == x2 && y == y2) return true;
		if(det(x1 - x, y1 - y, x2 - x, y2 - y) != 0) return false;
		return (x1 - x) * (x2 - x) + (y1 - y) * (y2 - y) < 0;
	}
	bool Intersects(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){

		int d0 = det0(x3 - x1, y3 - y1, x2 - x1, y2 - y1);
		int d1 = det0(x4 - x1, y4 - y1, x2 - x1, y2 - y1);
		if(d0 == 0 || d1 == 0 || d0 == d1) return false;
		int d2 = det0(x1 - x3, y1 - y3, x4 - x3, y4 - y3);
		int d3 = det0(x2 - x3, y2 - y3, x4 - x3, y4 - y3);
		if(d2 == 0 || d3 == 0 || d2 == d3) return false;
		return true;

	}

	int det (int a, int b, int c, int d){
		return a * d - b * c;
	}
	int det0 (int a, int b, int c, int d){
		var ret = a * d - b * c;
		if(ret == 0) return 0;
		if(ret > 0) return 1;
		return -1;
	}

	int[] A, B;
	public Sol(){
		A = ria();
		B = ria();
	}

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


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

namespace CodeForces
{
    static class Program
    {
        static void Main()
        {
            const string filePath = @"Data\R488C.txt";
            if (System.IO.File.Exists(filePath))
            {
                Console.SetIn(new System.IO.StreamReader(filePath));
            }

            IProblem counter = new R488C();

            foreach (var result in counter.GetResults())
            {
                Console.WriteLine(result);
            }
        }
    }

    internal class R488C : ProblemBase
    {
        public class Point
        {
            public double X { get; set; }
            public double Y { get; set; }
        }

        private double Area(Point a, Point b, Point c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }

        private bool HasProjectionIntersection(double a, double b, double c, double d)
        {
            double temp;
            if (a > b)
            {
                temp = a;
                a = b;
                b = temp;
            }

            if (c > d)
            {
                temp = c;
                c = d;
                d = temp;
            }
            return Math.Max(a, c) <= Math.Min(b, d);
        }

        private bool HasIntersection(Point a,  Point b, Point c, Point d)
        {
            return HasProjectionIntersection(a.X, b.X, c.X, d.X)
                   && HasProjectionIntersection(a.Y, b.Y, c.Y, d.Y)
                   && Area(a, b, c) * Area(a, b, d) <= 0
                   && Area(c, d, a) * Area(c, d, b) <= 0;
        }

        public override IEnumerable<string> GetResults()
        {
            var line = this.ReadIntArray();
            var first = new Point[4];
            for (int i = 0; i < 4; i++)
            {
                first[i] = new Point {X = line[2 * i], Y = line[2 * i + 1]};
            }

            var second = new Point[4];
            line = this.ReadIntArray();
            for (int i = 0; i < 4; i++)
            {
                second[i] = new Point { X = line[2 * i], Y = line[2 * i + 1] };
            }

            var hasIntersection = SimpleCheck(first, second);
            if (!hasIntersection)
            {
                var centerX = second.Sum(item => item.X) / 4.0;
                var centerY = second.Sum(item => item.Y) / 4.0;

                for (int i = 0; i < 4; i++)
                {
                    first[i].X -= centerX;
                    first[i].Y -= centerY;
                    second[i].X -= centerX;
                    second[i].Y -= centerY;
                }

                first = Rotate45(first);
                second = Rotate45(second);

                hasIntersection = SimpleCheck(second, first);
            }

            yield return hasIntersection? "YES" : "n/a";
        }

        private Point[] Rotate45(Point[] first)
        {
            var cos45 = Math.Cos(Math.PI / 4.0);
            var sin45 = Math.Sin(Math.PI / 4.0);
            var newPoints = new Point[4];
            for (int i = 0; i < 4; i++)
            {
                newPoints[i] = new Point
                {
                    X = cos45 * first[i].X + sin45 * first[i].Y,
                    Y = -sin45 * first[i].X + cos45 * first[i].Y
                };
            }

            return newPoints;
        }

        private bool SimpleCheck(Point[] first, Point[] second)
        {
            bool hasIntersection = false;
            for (int firstIndex = 0; firstIndex < 4; firstIndex++)
            {
                for (int secondIndex = 0; secondIndex < 4; secondIndex++)
                {
                    if (HasIntersection(first[firstIndex], first[(firstIndex + 1) % 4], second[secondIndex],
                        second[(secondIndex + 1) % 4]))
                    {
                        hasIntersection = true;
                        break;
                    }
                }
            }

            if (!hasIntersection)
            {
                var point = new Point
                {
                    X = second.Sum(item => item.X) / 4.0,
                    Y = second.Sum(item => item.Y) / 4.0
                };

                var minX = first[0].X;
                var maxX = first[0].X;
                var minY = first[0].Y;
                var maxY = first[0].Y;
                for (int i = 1; i < 4; i++)
                {
                    if (first[i].X < minX)
                    {
                        minX = first[i].X;
                    }

                    if (first[i].Y < minY)
                    {
                        minY = first[i].Y;
                    }

                    if (first[i].X > maxX)
                    {
                        maxX = first[i].X;
                    }

                    if (first[i].Y > maxY)
                    {
                        maxY = first[i].Y;
                    }
                }

                if (point.X <= maxX && point.X >= minX && point.Y >= minY && point.Y <= maxY)
                {
                    hasIntersection = true;
                }
            }

            return hasIntersection;
        }
    }

    internal class R488D : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    abstract class MultipleTestsBase : ProblemBase
    {
        public sealed override IEnumerable<string> GetResults()
        {
            var t = Convert.ToInt32(Console.ReadLine());
            for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)
            {
                foreach (var result in GetTestResult(testCaseNumber + 1))
                {
                    yield return result;
                }

            }

        }

        protected abstract IEnumerable<string> GetTestResult(int caseNumber);
    }

    public interface IProblem
    {
        IEnumerable<string> GetResults();
    }

    public abstract class ProblemBase : IProblem
    {
        public void PrintArray<T>(IEnumerable<T> items, string prefixMessage)
        {
            Console.WriteLine("{0}: {1}", prefixMessage, string.Join(",", items));
        }

        public void WriteDiagnostics(string message, params object[] objects)
        {
            Console.WriteLine(message, objects);
        }

        public virtual IEnumerable<string> GetResults()
        {
            yield return "No result";
        }

        protected int[] ReadIntArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt32);
        }

        protected long[] ReadLongArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt64);
        }

        protected string[] ReadTokens()
        {
            var readLine = Console.ReadLine();
            if (readLine == null)
            {
                throw new Exception("Value read from Console is null");
            }
            return readLine.Split(' ');
        }

        protected int ReadInt32()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
    }
}


using System;

class Program
{
    static void Main(string[] args)
    {
        int n = Convert.ToInt16(Console.ReadLine());
        string[] inp = Console.ReadLine().Split(' ');
        int p = Convert.ToInt16(inp[n - 2]);
        int c = Convert.ToInt16(inp[n - 1]);
        if (n == 1) Console.WriteLine(c == 15 ? "DOWN" : (c == 0 ? "UP" : "-1"));
        else
        {
            if (c > p) Console.WriteLine(c == 15 ? "DOWN" : "UP");
            else Console.WriteLine(c == 0 ? "UP" : "DOWN");
        }
    }
}


using System;
using System.Collections.Generic;

namespace Div._2_Vitya_in_the_Countryside
{
    class Program
    {
        static int szamoksz1;
        static int[] szamok = new int[2];
        static void Main(string[] args)
        {
            szamoksz1 = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            for (int i = szamoksz1-2; i < szamoksz1; i++)
            {
                szamok[i] = int.Parse(s[i]);
            }
            if (szamoksz1 == 1)
	        {
		        Console.Write(-1);
	        }
            else
                Console.Write(Megoldas());;
        }
        static string Megoldas()
        {
            if (szamok[0] < szamok[1] && szamok[1] != 15)
            {
                return "UP";
            }
            else if (szamok[0] > szamok[1] && szamok[1] != 0)
            {
                return "DOWN";
            }
            else if (szamok[1] == 15)
                return "DOWN";
            else
                return "UP";
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());
        static double ReadDouble() => double.Parse(Console.ReadLine());
        static string ReadString() => Console.ReadLine();
        static int[] ReadIntArray() => (Console.ReadLine().Split(' ')).Select(int.Parse).ToArray();
        static double[] ReadDoubleArray() => (Console.ReadLine().Split(' ')).Select(double.Parse).ToArray();
        static long[] ReadLongArray() => (Console.ReadLine().Split(' ')).Select(long.Parse).ToArray();
        static List<int> ReadIntList() => (Console.ReadLine().Split(' ')).Select(int.Parse).ToList();
        static List<long> ReadLongList() => (Console.ReadLine().Split(' ')).Select(long.Parse).ToList();
        static char[] ReadCharArray() => (Console.ReadLine().Split(' ')).Select(char.Parse).ToArray();

        public struct P {
            int x;
            int y;
            public P(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }

        static void Main(string[] args)
        {
            long n = ReadLong();
            long ans = 0;

            if (n % 2 == 0)
            {
                ans += n/2;
                n = 0;
            }
            for (long i = 3; i <= n; i+=2)
            {
                if (n % i == 0)
                {
                    ans++;
                    n -= i;
                    break;
                }
            }
            ans += n / 2;

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


using System;
using System.Collections.Generic;

namespace CSharp
{
    class _1076B
    {
        public static void Main()
        {
            long n = long.Parse(Console.ReadLine());

            var primes = new SortedSet<long>();
            for (long i = 2; ; i++)
            {
                bool isPrime = true;

                foreach (long p in primes)
                {
                    if (i % p == 0)
                    {
                        isPrime = false;
                        break;
                    }

                    if (i * i >= p)
                    {
                        break;
                    }
                }

                if (isPrime)
                {
                    primes.Add(i);

                    if (n % i == 0)
                    {
                        Console.WriteLine((n - i) / 2 + 1);
                        break;
                    }
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;

namespace Program
{
    class Program
    {
        static Dictionary<long, bool> primes = new Dictionary<long, bool>();
        static Dictionary<long, long> divisors = new Dictionary<long, long>();

        static long Sieve(long n)
        {
            if(divisors.ContainsKey(n)) return divisors[n];

            long root = (long)Math.Ceiling(Math.Sqrt(n));

            for (long i = 2; i <= root; i++)
            {
                if(!primes.ContainsKey(i))
                {
                    primes.Add(i, true);
                    if(n % i == 0)
                    {
                        divisors.Add(n, i);
                        return i;
                    }

                    long k = 1;

                    for (long j = i * i; j < n; )
                    {
                        if(!primes.ContainsKey(j)) primes.Add(j, false);
                        j = i * i + k * i;
                        k++;
                    }
                }
            }

            divisors.Add(n, n);
            return n;
        }

        static void Main(string[] args)
        {

            long n, count = 0, divisor;

            n = Convert.ToInt64(Console.ReadLine());

            while (true)
            {
                if(n == 0) break;

                if(n % 2 == 0)
                {
                    count += n / 2;
                    break;
                }

                divisor = Sieve(n);

                n -= divisor;

                count++;
            }

            Console.WriteLine(count);
        }
    }
}


using System;

class tf
{
    public static void Main()
    {
        long n = long.Parse(Console.ReadLine());

        int i = 3;
        int c = 0;

        var sqrt = Math.Sqrt(n);

        if(n % 2 == 0)
        {
            Console.WriteLine(n / 2);
            return;
        }
        while(i <= sqrt)
        {
            if(n % i == 0)
            {
                n -= i;
                c++;
                i = 2;
            }

            i+= 3;
        }

        if(i > sqrt) c= 1;

          Console.WriteLine(c);
    }
}


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

namespace CodeForces
{
    public class CodeForces
    {
        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());
            //var arr = GetArray();
            Console.WriteLine(Solve(n));
           // Tests();

        }

        public static void Tests()
        {
            //Solve(10, new int[] { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89});
        }

        public static long Solve(int n)
        {
            var sieve = new int[1000000];
            var primes = new List<int>();
            for (var i = 2; i < sieve.Length; i++)
            {
                if (sieve[i] == 1)
                    continue;

                primes.Add(i);
                var k = i + i;
                while(k < sieve.Length)
                {
                    sieve[k] = 1;
                    k += i;
                }
            }
            long cn = 0;
            while (n > 0)
            {
                for (var i = 0; i < primes.Count; i++)
                {
                    if (n % primes[i] == 0)
                    {
                        n -= primes[i];
                        cn++;
                        break;
                    }
                }
            }
            return cn;
        }

        static int[] GetArray()
        {
            return Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        }

    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Resources;
using System.Text;

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

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

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

			long n = long.Parse(input1);
			if (n % 2 == 0)
			{
				Console.WriteLine(n / 2);
				return;
			}

			long d = 3;
			while (n % d > 0)
			{
				d += 2;
			}

			if (n > d)
			{
				Console.WriteLine(1 + (n - d) / 2);
			}
			else
			{
				Console.WriteLine(1);
			}
		}

		public static void Print(int[] number)
		{
			var stringBuilder = new StringBuilder();
			foreach (var i in number)
			{
				if (i == 0 && stringBuilder.Length == 0)
				{
					continue;
				}

				stringBuilder.Append(i);
			}

			Console.WriteLine(stringBuilder.ToString());
		}

		public void Method1(ref int n1, ref int n2, ref int k1, ref int k2)
		{
			double a = (double)n1 / k1;
			double b = (double)n2 / k2;
			if (n1 >= n2 || (a >= b && a < 2 * b))
			{

			}
		}

		public void Method2(ref int n1, ref int n2, ref int k1, ref int k2)
		{
			double a = (double)n1 / k1;
			double b = (double)n2 / k2;
			if (n2 >= n1 || (b >= a && b < 2 * a))
			{

			}
		}

		public class Node
		{
			public int Count { get; set; }

			public int FirstIndex { get; set; } = -1;

			public int LastIndex { get; set; } = -1;
		}

		//public class Node<T>
		//{
		//	public Node<T> Left { get; set; }

		//	public Node<T> Right { get; set; }

		//	public T Value { get; set; }

		//	public Node(T value)
		//	{
		//		Value = value;
		//	}
		//}

		//public class Tree<T>
		//{
		//	public Node<T> Root { get; set; }

		//	public Tree(T value)
		//	{
		//		Root = new Node<T>(value);
		//	}
		//}

		private static long GCD(long a, long b)
		{
			long max = Math.Max(a, b);
			long min = Math.Min(a, b);

			if (min == 0)
			{
				return max;
			}

			a = min;
			b = max % min;
			return GCD(a, b);
		}

		private static long LCM(long a, long b)
		{
			return Math.Abs(a * b) / GCD(a, b);
		}

		//private static int Length(short[] a)
		//{
		//	int firstItemIndex = 0;
		//	for (int i = 0; i < a.Length; i++)
		//	{
		//		if (a[i] == 0)
		//		{
		//			continue;
		//		}

		//		firstItemIndex = i;
		//		break;
		//	}

		//	return a.Length - firstItemIndex;
		//}

		//private static short[] Subtract(short[] a, short[] b)
		//{
		//	if (a.Length != b.Length)
		//	{
		//		throw new ArgumentException();
		//	}

		//	short[] result = new short[a.Length];
		//	Array.Copy(a, result, a.Length);
		//	for (int i = result.Length - 1; i >= 0; i--)
		//	{
		//		if (result[i] < b[i])
		//		{
		//			int j = i - 1;
		//			while (result[j] == 0)
		//			{
		//				result[j--] = 9;
		//			}

		//			result[j]--;
		//			result[i] += 10;
		//		}

		//		result[i] -= b[i];
		//	}

		//	return result;
		//}

		//private static short[] Multiply(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	for (int i = a.Length - 1; i > 0; i--)
		//	{
		//		int temp = a[i] * b;
		//		result[i] = (short)(result[i] + temp % 10);
		//		result[i - 1] = (short)(result[i - 1] + temp / 10);
		//	}

		//	return result;
		//}

		//private static int Mod(short[] a, int b)
		//{
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		rest = d % b;
		//		i++;
		//	}

		//	return rest;
		//}

		//private static short[] Divide(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		result[i] = (short)(d / b);
		//		rest = d % b;
		//		i++;
		//	}

		//	return result;
		//}
	}
}


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

namespace Shower_Line
{
    class Program
    {
        static void Main(string[] args)
        {
            IO io = new IO();
            const int i_Num = 5;
            int[,] td_arr_Inputs = new int[i_Num,i_Num];

            for(int i =0;i<i_Num;i++)
            {
                for(int j=0;j<i_Num;j++)
                {
                    td_arr_Inputs[i,j]=io.ReadNextInt();
                }
            }

            #region
            int i_Max = 0;
            for (int i = 1; i <= i_Num; i++)
            {
                for (int j = 1; j <= i_Num; j++)
                {
                    for (int p = 1; p <= i_Num; p++)
                    {
                        for (int q = 1; q <= i_Num; q++)
                        {
                            for (int k = 1; k <= i_Num; k++)
                            {
                                if (i != j && i != k && i != p && i != q && j != k && j != p && j != q && k != p && k != q && p != q)
                                {
                                    if (td_arr_Inputs[i,j] + td_arr_Inputs[j,i] +
                                        td_arr_Inputs[p,q] + td_arr_Inputs[q,p] +
                                        td_arr_Inputs[j,p] + td_arr_Inputs[p,j] +
                                        td_arr_Inputs[q,k] + td_arr_Inputs[k,q] +
                                        td_arr_Inputs[p,q] + td_arr_Inputs[q,p] +
                                        td_arr_Inputs[q, k] + td_arr_Inputs[k, q] > i_Max)
                                    {
                                        i_Max = td_arr_Inputs[i, j] + td_arr_Inputs[j, i] +
                                            td_arr_Inputs[p,q] + td_arr_Inputs[q,p] +
                                            td_arr_Inputs[j,p] + td_arr_Inputs[p,j] +
                                            td_arr_Inputs[q,k] + td_arr_Inputs[k,q] +
                                            td_arr_Inputs[p,q] + td_arr_Inputs[q,p] +
                                            td_arr_Inputs[q,k] + td_arr_Inputs[k,q];
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            io.PutStr(i_Max);
            io.ReadInt();
        }
    }

    class IO
    {
        private static Queue<string> currentLineTokens = new Queue<string>();
        private static string[] ReadAndSplitLine()
        {
            return Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }
        public int ReadNextInt()
        {
            return int.Parse(ReadToken());
        }
        public long ReadNextLong()
        {
            return long.Parse(ReadToken());
        }

        public int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        public long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        public string ReadStr()
        {
            return Console.ReadLine();
        }
        public string[] ReadStrArr()
        {
            return Console.ReadLine().Split(' ');
        }
        public int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), s => int.Parse(s));
        }
        public long[] ReadLongArr()
        {
            return Array.ConvertAll<string, long>(Console.ReadLine().Split(' '), s => long.Parse(s));
        }
        public void PutStr(string str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(int str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(long str)
        {
            Console.WriteLine(str);
        }

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


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

namespace Tournir247
{
	class ProgramB
	{

		public static void Main(string[] args)
		{
			new ProgramB().run();
		}

		public void run()
		{
			using (StreamReader input = new StreamReader("input.txt"))
			using (StreamWriter output = new StreamWriter("output.txt"))
			{
				int[][] g = new int[5][];

				for (int i = 0; i < g.GetLength(0); i++)
				{
					g[i] = input.ReadLine().Split(' ').Select(stringNumber => int.Parse(stringNumber)).ToArray();
				}

				for (int i = 0; i < 5; i++)
				{
					for (int j = i + 1; j < 5; j++)
					{
						g[i][j] = g[j][i] = g[i][j] + g[j][i];
					}
				}

				long maxJoi = 0;

				for (int a1 = 0; a1 < 5; a1++)
					for (int a2 = 0; a2 < 5; a2++)
						if (a2 != a1)
							for (int a3 = 0; a3 < 5; a3++)
								if (a3 != a1 && a3 != a2)
									for (int a4 = 0; a4 < 5; a4++)
										if (a4 != a1 && a4 != a2 && a4 != a3)
											for (int a5 = 0; a5 < 5; a5++)
												if (a5 != a1 && a5 != a2 && a5 != a3 && a5 != a4)
												{
													long joi = getJoi(g, a1, a2, a3, a4, a5);
													if (joi > maxJoi)
														maxJoi = joi;
												}
				output.Write(maxJoi);
			}
		}

		public long getJoi(int[][] g, int a1, int a2, int a3, int a4, int a5)
		{
			return g[a1][a2] + g[a3][a4] + g[a2][a3] + g[a4][a5] + g[a3][a4] + g[a4][a5];
		}

	}
}


using System;

class test
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine()),
        k = int.Parse(Console.ReadLine()),
        x = int.Parse(Console.ReadLine()),r = 0;
        for (int i = 0; i < n - k; i++)
            r += int.Parse(Console.ReadLine());
        for (int i = 0; i < k; i++)
        {
            Console.ReadLine();
            r += x;
        }
        Console.WriteLine(r);
    }
}


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

namespace CodeforcesTemplate
{
    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {
#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            int[] toks = ReadIntArray();

            int n = toks[0];
            int x = toks[1];

            int[] arr = ReadIntArray();

            RunTimer();

            Array.Sort(arr);

            int count = 0;

            for (int i = 0; i <= x; i++)
            {
                if (!arr.Contains(i) && i != x)
                {
                    count++;
                }

                if (i == x && arr.Contains(x))
                {
                    count++;
                }

            }

            Console.WriteLine(count);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] ReadIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] ReadDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}


using System;
using System.Collections.Generic;

namespace CodeForceCs
{
    static class Program
    {
        static void Main(string[] args)
        {
            Solver solver = new _462_2D();
            solver.SolveProblem();
            //Console.ReadKey();
        }
    }

    static class Utility
    {
        static public T[] NewArrayWithValue<T>(int length, T value)
        {
            T[] array = new T[length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = value;
            }
            return array;
        }
    }

    abstract class Solver
    {
        abstract public void SolveProblem();
    }

    class _462_2D : Solver
    {
        Int64 p, k, z;
        int d;
        List<Int64> a, q;
        String result;
        public override void SolveProblem()
        {
            String[] input = Console.ReadLine().Split();
            p = Int64.Parse(input[0]);
            k = Int64.Parse(input[1]);
            a = new List<Int64>();
            q = new List<Int64>();

            d = 1;
            z = p % k;
            a.Add(z);
            q.Add((z - p) / k);

            while (!(q[d-1] >= 0 && q[d-1] < k))
            {
                z = q[d - 1] % k;
                if (z < 0)
                    z += k;
                a.Add(z);
                q.Add((z - q[d - 1]) / k);
                d++;
            }
            a.Add(q[d - 1]);

            Console.WriteLine(d+1);

            result = "";
            foreach (Int64 v in a)
                result += v + " ";
            Console.WriteLine(result);

            //result = "";
            //foreach (Int64 v in q)
            //    result += v + " ";
            //Console.WriteLine(result);
        }
    }

    class _462_2C : Solver
    {
        List<int> a;
        int n, result;

        public override void SolveProblem()
        {
            a = new List<int>();
            n = int.Parse(Console.ReadLine());
            result = Math.Min(n, 2);

            String[] input = Console.ReadLine().Split();
            foreach (String s in input)
                a.Add(int.Parse(s));

            for (int i = 1; i < n-1; i++)
            {
                result = Math.Max(result, GetMaxNonDec(0, i) + GetMaxNonDec(i, n - i));
            }
            Console.WriteLine(result);

        }

        int GetMaxNonDec(int start, int length)
        {
            if (length <= 0)
                return 0;

            int[] oneNum, twoNum;
            oneNum = new int[length];
            twoNum = new int[length];
            oneNum[0] = a[start] == 1 ? 1 : 0;
            twoNum[0] = a[start + length - 1] == 2 ? 1 : 0;

            for (int i = 1; i < length; i++ )
            {
                oneNum[i] = oneNum[i-1];
                twoNum[i] = twoNum[i-1];
                if (a[start + i] == 1)
                    oneNum[i]++;
                if (a[start + length - 1 - i] == 2)
                    twoNum[i]++;
            }

            int result = Math.Min(length, 2);
            for (int i = 0; i < length; i++)
                result = Math.Max(result, oneNum[i] + twoNum[length - i - 1]);
            return result;
        }
    }

    class _462_2B : Solver
    {
        String result = "";
        int k;
        public override void SolveProblem()
        {
            k = int.Parse(Console.ReadLine());
            if (k > 36)
            {
                Console.WriteLine("-1");
                return;
            }
            while (k > 1)
            {
                result += "8";
                k -= 2;
            }
            if (k == 1)
                result += "6";
            Console.WriteLine(result);
        }
    }

    class _462_2A : Solver
    {
        int n, m;
        List<Int64> a, b;
        Int64 result;
        public override void SolveProblem()
        {
            a = new List<Int64>();
            b = new List<Int64>();

            String[] input = Console.ReadLine().Split();
            n = int.Parse(input[0]);
            m = int.Parse(input[1]);

            input = Console.ReadLine().Split();
            foreach (String s in input)
                a.Add(Int64.Parse(s));

            input = Console.ReadLine().Split();
            foreach (String s in input)
                b.Add(Int64.Parse(s));

            a.Sort();
            b.Sort();

            Int64 p11, p12, p21, p22;
            p11 = Math.Max(a[1] * b[0], a[1] * b[m-1]);
            p12 = Math.Max(a[n - 1] * b[0], a[n - 1] * b[m - 1]);
            p21 = Math.Max(a[0] * b[0], a[0] * b[m - 1]);
            p22 = Math.Max(a[n - 2] * b[0], a[n - 2] * b[m - 1]);

            result = Math.Min(Math.Max(p11, p12), Math.Max(p21, p22));

            Console.WriteLine(result);
        }
    }

    class _910A : Solver
    {
        int n, d;
        int[] minstep;
        string lily;
        override public void SolveProblem()
        {
            var input = Console.ReadLine().Split();
            n = int.Parse(input[0]);
            d = int.Parse(input[1]);
            lily = Console.ReadLine();
            minstep = Utility.NewArrayWithValue<int>(n+1, 999);
            minstep[1] = 0;

            for (int i = 2; i <= n; i++)
            {
                for (int j = i; j >= Math.Max(1, i-d); j--)
                {
                    if (lily[j-1] == '0')
                        continue;

                    minstep[i] = Math.Min(minstep[i], minstep[j] + 1);
                }
            }

            if (minstep[n] > n)
                Console.WriteLine(-1);
            else
                Console.WriteLine(minstep[n]);
        }

    }
}


using System;
class Program
{
    static int Main()
    {
        int n=Int32.Parse(Console.ReadLine());
        int k=0;
        do{
            if(n>99)
            n-=100;
            else if(n>19)
            n-=20;
            else if(n>9)
            n-=10;
            else if(n>4)
            n-=5;
            else if(n>0)
            n-=1;
            k++;
        }while(n>-1);
        Console.WriteLine(k);
        return 0;
    }
}


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

namespace Allen
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] numbers = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int quantityOFcash = 0;
            while(numbers[0] - 100 >= 0)
            {
                if (numbers[0] - 100 >= 0)
                {
                    quantityOFcash++;
                    numbers[0] -= 100;
                }
            }
            while (numbers[0] - 20 >= 0)
            {
                if (numbers[0] - 20 >= 0)
                {
                    quantityOFcash++;
                    numbers[0] -= 20;
                }
            }
            while (numbers[0] - 10 >= 0)
            {
                if (numbers[0] - 10 >= 0)
                {
                    quantityOFcash++;
                    numbers[0] -= 10;
                }
            }
            while (numbers[0] - 5 >= 0)
            {
                if (numbers[0] - 5 >= 0)
                {
                    quantityOFcash++;
                    numbers[0] -= 5;
                }
            }
            while (numbers[0] - 1 >= 0)
            {
                if (numbers[0] - 1 >= 0)
                {
                    quantityOFcash++;
                    numbers[0] -= 1;
                }
            }
            Console.WriteLine(quantityOFcash);
        }


using System;
using static System.Math;
using System.Linq;

namespace ConsoleApplication
{
    sealed class Program
    {
        static void Main(string[] args)
        {
            var n = Int32.Parse(Console.ReadLine());
            mem = new int[n + 1];
            Console.WriteLine(F(n));
        }

        private static int[] mem;

        static int F(int n)
        {
            if (n < 0)
                return 1000000;
            if (n % 100 == 0)
                return n / 100;
            if (n == 1)
                return 1;
            if (mem[n] == 0)
                mem[n] = Min(Min(F(n - 1), F(n - 5)), Min(Min(F(n - 10), F(n - 20)), F(n - 100))) + 1;
            return mem[n];
        }
    }
}


using System;
using static System.Math;
using System.Linq;

namespace ConsoleApplication
{
    sealed class Program
    {
        static void Main(string[] args)
        {
            var n = Int64.Parse(Console.ReadLine());
            mem = new int[n + 1];
            Console.WriteLine(F(n));
        }

        private static long[] mem;

        static long F(long n)
        {
            if (n < 0)
                return 1000000;
            if (n % 100 == 0)
                return n / 100;
            if (n == 1)
                return 1;
            if (mem[n] == 0)
                mem[n] = Min(Min(F(n - 1), F(n - 5)), Min(Min(F(n - 10), F(n - 20)), F(n - 100))) + 1;
            return mem[n];
        }
    }
}


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

namespace C
{
    class Program
    {
        //static void nok(int a, int b)
        //{
        //    while()
        //}

        static void Main(string[] args)
        {
            TextReader sr = Console.In;
            //StreamReader sr = new StreamReader("in1.txt");
            string[] s1 = sr.ReadLine().Split();
            int la = Convert.ToInt32(s1[0]);
            int ra = Convert.ToInt32(s1[1]);
            int ta = Convert.ToInt32(s1[2]);
            s1 = sr.ReadLine().Split();
            int lb = Convert.ToInt32(s1[0]);
            int rb = Convert.ToInt32(s1[1]);
            int tb = Convert.ToInt32(s1[2]);
            long ok = (long)ta * (long)tb;

            int uda = ra - la + 1; //кол-во удачных денй у Алисы
            int nuda =ta- uda; //кол-во не удачных денй у Алисы
            int udb = rb - lb + 1; //кол-во удачных денй у Боба
            int nudb = tb-udb; //кол-во не удачных денй у Боба

            bool suda, sudb;
            int ddsua,ddsub;
            if (la == 0)
            {
                suda = true;//удачный ли сегодня день у Алисы
                ddsua = uda;//через скольо дней удача изменит Алисе
            }
            else
            {
                suda = false;
                ddsua = la;
            }
            if (lb == 0)
            {
                sudb = true;//удачный ли сегодня день у Боба
                ddsub = udb;//через скольо дней удача изменит Бобу
            }
            else
            {
                sudb = false;
                ddsub = lb;
            }

            int tdp = 0;//текущая длинна последовательности удачных дней
            int mdp = 0;//максимальная длина подходящей последовательности (ответ)
            for (long i = 0; i < ok; i++)
            {
                if (suda && sudb)
                {
                    tdp++;
                    if (tdp > mdp) mdp = tdp;
                }
                else
                {
                    tdp = 0;
                }
                //определяем следующие знаяения удачи(для следующего дня)
                ddsua--;
                if (ddsua == 0)
                {
                    if (suda) ddsua = nuda;
                    else ddsua = uda;
                    suda = !suda;
                }
                ddsub--;
                if (ddsub == 0)
                {
                    if (sudb) ddsub = nudb;
                    else ddsub = udb;
                    sudb = !sudb;
                }

            }

            Console.WriteLine(mdp);
        }
    }
}


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

namespace C
{
    class Program
    {
        //static void nok(int a, int b)
        //{
        //    while()
        //}

        static void Main(string[] args)
        {
            //TextReader sr = Console.In;
            StreamReader sr = new StreamReader("in100.txt");
            string[] s1 = sr.ReadLine().Split();
            int la = Convert.ToInt32(s1[0]);
            int ra = Convert.ToInt32(s1[1]);
            int ta = Convert.ToInt32(s1[2]);
            s1 = sr.ReadLine().Split();
            int lb = Convert.ToInt32(s1[0]);
            int rb = Convert.ToInt32(s1[1]);
            int tb = Convert.ToInt32(s1[2]);
            long ok = (long)ta * (long)tb;

            int uda = ra - la + 1; //кол-во удачных денй у Алисы
            int nuda =ta- uda; //кол-во не удачных денй у Алисы
            int udb = rb - lb + 1; //кол-во удачных денй у Боба
            int nudb = tb-udb; //кол-во не удачных денй у Боба

            int min_la_lb = int.MaxValue;
            int min_ra_rb = int.MaxValue;
            long lai = (long)la;
            long lbi = (long)lb;

            long tdp = 0;//текущая длинна последовательности удачных дней
            long mdp = 0;//максимальная длина подходящей последовательности (ответ)

            while (lai<ok && lbi<ok)
            {
                //if (Math.Abs(lai - lbi) < Math.Abs(min_la_lb)) min_la_lb = Convert.ToInt32(lai - lbi);
                if (lai - lbi == 0)
                {
                    mdp = Math.Min(uda, udb);
                    break;
                }
                else if (lai < lbi)
                {
                    tdp = Math.Min(uda - (lbi - lai), udb);
                    lai = lai + ta;
                }
                else
                {
                    tdp = Math.Min(uda, udb-(lai - lbi));
                    lbi = lbi + tb;
                }
                mdp = Math.Max(mdp, tdp);
            }

            //bool suda, sudb;
            //int ddsua,ddsub;
            //if (la == 0)
            //{
            //    suda = true;//удачный ли сегодня день у Алисы
            //    ddsua = uda;//через скольо дней удача изменит Алисе
            //}
            //else
            //{
            //    suda = false;
            //    ddsua = la;
            //}
            //if (lb == 0)
            //{
            //    sudb = true;//удачный ли сегодня день у Боба
            //    ddsub = udb;//через скольо дней удача изменит Бобу
            //}
            //else
            //{
            //    sudb = false;
            //    ddsub = lb;
            //}

            //int tdp = 0;//текущая длинна последовательности удачных дней
            //int mdp = 0;//максимальная длина подходящей последовательности (ответ)
            //for (long i = 0; i < ok; i++)
            //{
            //    if (suda && sudb)
            //    {
            //        tdp++;
            //        if (tdp > mdp) mdp = tdp;
            //    }
            //    else
            //    {
            //        tdp = 0;
            //    }
            //    //определяем следующие знаяения удачи(для следующего дня)
            //    ddsua--;
            //    if (ddsua == 0)
            //    {
            //        if (suda) ddsua = nuda;
            //        else ddsua = uda;
            //        suda = !suda;
            //    }
            //    ddsub--;
            //    if (ddsub == 0)
            //    {
            //        if (sudb) ddsub = nudb;
            //        else ddsub = udb;
            //        sudb = !sudb;
            //    }

            //}

            Console.WriteLine(mdp);
        }
    }
}


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

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

class Sol{
	public void Solve(){
		long mT = 100000L;
		if(Tb < mT){
			var h = new Dictionary<long,long>();
			for(long k=0;k<Tb;k++){
				if(h.ContainsKey((La + k * Ta) % Tb)) continue;
				h.Add((La + k * Ta) % Tb, 1);
			}
			List<long> hl = h.Keys.ToList();
			hl.Sort();
			int l = 0, r = hl.Count;
			long max = 0;
			if(hl[l] >= Lb){
				if(hl[l] > Rb){
					max = Math.Max(max, 0);
				} else {
					max = Math.Max(max, Math.Min(hl[l] + (Ra - La), Rb) - hl[l] + 1);
				}
				Console.WriteLine(max);
				return;
			}
			while(r - l > 1){
				int c = (r + l) / 2;
				if(hl[c] < Lb){
					l = c;
				} else {
					r = c;
				}
			}

			if(r < hl.Count){
				max = Math.Max(max, Math.Min(hl[r] + (Ra - La), Rb) - hl[r] + 1);
			}
			max = Math.Max(max, Math.Min(hl[l] + (Ra - La), Rb) - Math.Max(Lb, hl[l]) + 1);

			Console.WriteLine(max);

		} else {

			var h = new Dictionary<long,long>();
			for(long k=0;k<Tb;k++){
				if(h.ContainsKey((La + k * Ta) % Tb)) continue;
				h.Add((La + k * Ta) % Tb, 1);
			}
			List<long> hl = h.Keys.ToList();
			hl.Sort();
			int n = hl.Count;
			for(int i=0;i<n;i++) hl.Add(hl[i] + Tb);
			for(int i=0;i<n;i++) hl.Add(hl[i] + 2 * Tb);

			long max = 0;
			for(int j=0;j<Tb / mT;j++){
				var lb = (Lb - j * mT * Ta) % Tb;
				var rb = (Rb - j * mT * Ta) % Tb;
				if(lb < 0) lb += Tb;
				if(rb < 0) rb += Tb;
				if(rb < lb) rb += Tb;

				if(lb < Tb){
					lb += Tb;
					rb += Tb;
				}

				int l = 0, r = hl.Count;
				if(hl[l] >= lb){
					if(hl[l] > rb){
						max = Math.Max(max, 0);
					} else {
						max = Math.Max(max, Math.Min(hl[l] + (Ra - La), lb) - hl[l] + 1);
					}
					continue;
				}
				while(r - l > 1){
					int c = (r + l) / 2;
					if(hl[c] < lb){
						l = c;
					} else {
						r = c;
					}
				}

				if(r < hl.Count){
					max = Math.Max(max, Math.Min(hl[r] + (Ra - La), rb) - hl[r] + 1);
				}
				max = Math.Max(max, Math.Min(hl[l] + (Ra - La), rb) - Math.Max(lb, hl[l]) + 1);
			}
			Console.WriteLine(max);
		}

	}
	long La,Lb,Ra,Rb,Ta,Tb;
	public Sol(){

		//var d = rla();
		var ss = rsa();
		long[] d = new long[3];
		for(int i=0;i<3;i++) d[i] = long.Parse(ss[i]);
		La = d[0]; Ra = d[1]; Ta = d[2];
		//d = rla();
		ss = rsa();
		d = new long[3];
		for(int i=0;i<3;i++) d[i] = long.Parse(ss[i]);
		Lb = d[0]; Rb = d[1]; Tb = d[2];

	}

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


using System;
using System.Linq;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    int N, K;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();

        /*
         * n行n列　タイル　白or黒
         * 隣接する行 すべて同じか違うかつ
         * k個以上の単色のタイルの長方形が存在しないならbeautiful
         *
         * beautifulなパターン数
         *
         */

        /*
         * 最大の連続がxの列
         *
         * O(n^3)で調べる
         *
         */

        // iまで見る、現在連続j 連続最大k
        var row = new ModInt[N + 1, N + 1, N + 1];
        row[1, 1, 1] = 2;
        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j <= i; j++)
            {
                for (int k = j; k <= i; k++)
                {
                    // 同色
                    if (j + 1 <= N) row[i + 1, j + 1, Math.Max(j + 1, k)] += row[i, j, k];
                    // 別
                    row[i + 1, 1, k] += row[i, j, k];
                }
            }
        }

        ModInt ans = 0;
        for (int x = 1; x < K && x <= N; x++)
        {
            var t = (K - 1) / x;
            var dp = new ModInt[N + 1, t + 1];
            dp[1, 1] = 1;

            for (int i = 1; i < N; i++)
            {
                for (int j = 1; j <= t; j++)
                {
                    if (j + 1 <= t) dp[i + 1, j + 1] += dp[i, j];
                    dp[i + 1, 1] += dp[i, j];
                }
            }

            ModInt s = 0;
            for (int y = 1; y <= t; y++)
            {
                s += dp[N, y];
            }
            ModInt u = 0;
            for(int j = 1;j <= x; j++)
            {
                u += row[N, j, x];
            }
            ans += s * u;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        // public const long Mod = (int)1e9 + 7;
        public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <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); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <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); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <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);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public 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];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Linq;
using CompLib.Mathematics;
using CompLib.Util;

public class Program
{
    int N, K;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();

        /*
         * n行n列　タイル　白or黒
         * 隣接する行 すべて同じか違うかつ
         * k個以上の単色のタイルの長方形が存在しないならbeautiful
         *
         * beautifulなパターン数
         *
         */

        /*
         * 最大の連続がxの列
         *
         * O(n^3)で調べる
         *
         */

        // iまで見る、現在連続j 最大連続k

        // iは2で割ったあまり
        var row = new ModInt[2, N + 1, N + 1];
        row[1, 1, 1] = 2;
        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                for (int k = 1; k <= N; k++)
                {
                    row[(i + 1) & 1, j, k] = 0;
                }
            }
            for (int j = 1; j <= i; j++)
            {
                for (int k = j; k <= i; k++)
                {
                    // 同色
                    row[(i + 1) & 1, j + 1, Math.Max(j + 1, k)] += row[i & 1, j, k];
                    // 別色
                    row[(i + 1) & 1, 1, k] += row[i & 1, j, k];
                }
            }
        }

        ModInt ans = 0;
        for (int x = 1; x < K && x <= N; x++)
        {
            var t = (K - 1) / x;

            // i行目、連続j列同じ
            // iは2でわったあまり
            var dp = new ModInt[2, t + 1];
            dp[1, 1] = 1;

            for (int i = 1; i < N; i++)
            {
                for (int j = 1; j <= t; j++)
                {
                    dp[(i + 1) & 1, j] = 0;
                }
                for (int j = 1; j <= t; j++)
                {
                    if (j + 1 <= t) dp[(i + 1) & 1, j + 1] += dp[i & 1, j];
                    dp[(i + 1) & 1, 1] += dp[i & 1, j];
                }
            }

            ModInt s = 0;
            for (int y = 1; y <= t; y++)
            {
                s += dp[N & 1, y];
            }
            ModInt u = 0;
            for (int j = 1; j <= x; j++)
            {
                u += row[N & 1, j, x];
            }
            ans += s * u;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt
    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        // public const long Mod = (int)1e9 + 7;
        public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;
        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n) { num = n; }
        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <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); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <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); }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <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);
        }
        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
    }
    #endregion
    #region Binomial Coefficient
    public 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];
        }
    }
    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

class Solver
{
    public void Solve()
    {
		var ss = CF.ReadLine().Split(' ');
		int n = int.Parse(ss[0]);
		int m = int.Parse(ss[1]);
		int a = int.Parse(ss[2]);
		int b = int.Parse(ss[3]);

		int l1 = (a - 1) / m;
		int l2 = (b - 1) / m;
		int p1 = (a - 1) % m;
		int p2 = (b - 1) % m;

		if (b == n)
			p2 = m - 1;

		int res = 0;
		if (l1 == l2)
			res = 1;
		else if (l1 + 1 == l2)
		{
			res = 2;
			if ( p1 == 0 && p2 == m-1 )
				res--;
		}
		else
		{
			res = 3;

			if (p1 == 0)
				res--;

			if (p2 == m-1 )
				res--;

			if (res > 2 && p1+1== p2)
				res--;
		}

		CF.WriteLine(res);
    }

	//  test
	static Utils CF = new Utils(new[]{
@"
11 4 3 9
"
,

@"
20 5 2 20
"
,

@"
21 5 1 15
"

	});

    #region test

    static void Main(string[] args)
    {
#if DEBUG
        for (int t=0;t<CF.TestCount;t++ )
        {
            CF.Test(t);
            new Solver().Solve();
        }
#else
        new Solver().Solve();
#endif
    }

    class Utils
    {
        public void Test(int t)
        {
            _lines = new List<string>();
            string[] ss = _test_input[t].Replace("\n", "").Split('\r');
            for (int i = 0; i < ss.Length; i++)
            {
                if (
                    (i == 0 || i == ss.Length - 1) &&
                    ss[i].Length == 0
                    )
                    continue;

                _lines.Add(ss[i]);
            }
        }

        public int TestCount
        {
            get
            {
                return _test_input.Length;
            }
        }

        public string ReadLine()
        {
#if DEBUG
            string s = null;
            if (_lines.Count > 0)
            {
                s = _lines[0];
                _lines.RemoveAt(0);
            }
            return s;

#else
            //return _sr.ReadLine();
        return Console.In.ReadLine();
#endif
        }

        public void WriteLine(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.WriteLine(o);
#else
            //_sw.WriteLine(o);
        Console.WriteLine(o);
#endif
        }

        public void Write(object o)
        {
#if DEBUG
            System.Diagnostics.Trace.Write(o);
#else
                //_sw.Write(o);
        Console.Write(o);
#endif
        }

        string[] _test_input;

        List<string> _lines;

#if DEBUG
        public Utils(string[] test_input)
        {
            _test_input = test_input;
        }
#else

        public Utils(string[] dummy)
        {
            //_sr = new System.IO.StreamReader("input.txt");
            //_sw = new System.IO.StreamWriter("output.txt");
        }
#endif

    }

    #endregion
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int a = int.Parse(s[2]);
            int b = int.Parse(s[3]);
            int res;
            if (b != n)
            {
                if (a / m == b / m) res = 1;
                else
                {
                    if ((b / m - a / m) == 1)
                    {
                        if (b % m == 0 && a % m == 1) res = 1;
                        else res = 2;
                    }
                    else
                    {
                        if (b % m == 0 && a % m == 1) res = 1;
                        else if (b % m == 0 || a % m == 1) res = 2;
                        else res = 3;
                    }
                }
                if (a % m == b % m + 1 && b % m != 0)
                    res = 2;
            }
            else
            {
                if (a / m == b / m) res = 1;
                else
                {
                    if (a % m == 1) res = 1;
                    else res = 2;
                }

            }
            Console.WriteLine(res);
        }
    }
}


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

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

        private static void Solve()
        {
            var MOD = 1000000007;
            var input = ReadIntArray();
            var n = input[0];
            var m = input[1];
            var k = input[2];
            var dp = new List<List<long>>();
            for (int i = 0; i <= 1001; i++)
            {
                dp.Add(new List<long>());
                for (int j = 0; j <= i; j++)
                {
                    if(j == 0 || j == i)
                        dp[i].Add(1);
                    else
                    {
                        dp[i].Add((dp[i-1][j-1] + dp[i - 1][j]) % MOD);
                    }
                }
            }
            var res = dp[n - 1][Math.Min(2 * k, n-1)] * dp[m - 1][Math.Min(2 * k, m-1)];
            res %= MOD;
            Console.WriteLine(res);
        }

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

            Solve();

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

        #region Reader

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

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

        private static int[] ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
            return input;
        }

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

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

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

        #endregion
    }
}


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

namespace DNO
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int sum = 0;
            for (int i = 1; i <= n; i++)
                sum += i.ToString().Length;
            Console.Write(sum);
        }
    }
}


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int u = 0;
            for (int i = 1; i <=n ; i++)
            {
                string s = i.ToString();
                u += s.Count();

            }
            Console.WriteLine(u);

        }
    }
}


using System;

namespace _977A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string words = Console.ReadLine();
                //check if string is null or empty
                if (string.IsNullOrEmpty(words) == false)
                {
                    string[] seperatedWords = words.Split(' ');
                    int number = Convert.ToInt32(seperatedWords[0]);
                    int k = Convert.ToInt32(seperatedWords[1]);
                    if (((2 <= number) && (number <= 1000000000)) && ((1 <= k) && (k <= 50)))
                    {
                        for (int i = 0; i < k; i++)
                        {
                            if (number % 10 == 0)
                            {
                                number = number / 10;
                            }
                            else
                            {
                                number--;
                            }
                        }
                        //check if the number diviseble by 10

                    }
                    Console.WriteLine(number);
                }
            }

        }
    }
}


using System;

namespace C_
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            int k = Int32.Parse(Console.ReadLine());
            for(int i = 0; i < k; i++){
                string storer = Convert.ToString(n);
                if(storer[storer.Length - 1] == '0'){
                    n = n/10;
                }
                else{
                    n--;
                }
            }
            System.Console.WriteLine(n);
        }
    }
}


        public static void  Main(string[] args)
        {
            string nk= Console.ReadLine();
            string astr = Console.ReadLine();
            int n = Convert.ToInt32(nk.Split(' ')[0]);
            int k = Convert.ToInt32(nk.Split(' ')[1]);
            int ind = 0,saved=0,given=0;
            for (int i=0; i< n;i++)
            {
               int aday= Convert.ToInt32((astr.Split(' ')[i]));
                if (aday > 8)
                {
                    saved += aday - 8;
                    aday = 8;
                }
                if (aday < 8 && saved > 0)
                {
                    while (aday <= 8 && saved > 0)
                    {
                        aday++;
                        saved--;
                    }
                }
                given += aday;
                ind += 1;
                if (given >= k)
                { Console.WriteLine(ind); return; }
            }
            Console.WriteLine(-1);

        }


using System;
using System.Text.RegularExpressions;

namespace contest839a
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string NnK = Console.ReadLine();
            string candy = Console.ReadLine();

            int n = 0;
            int k = 0;

            int[] candies = new int[100];
            int count = 0;

            string[] nnk = NnK.Split(' ');

            n = Convert.ToInt32(nnk[0]);
            k = Convert.ToInt32(nnk[1]);

            MatchCollection amounts = Regex.Matches(candy, @"(\d+)");

            foreach (Match amount in amounts)
            {
                candies[count] = Convert.ToInt32(amount.Value);
                count++;
            }

            int minDays = 0;

            int currentCandy = 0;
            int totalGiven = 0;

            if(n * 8 < k){
                Console.WriteLine(-1);
                return;
            }

                while (totalGiven < k)
                {
                    currentCandy += candies[minDays];
                    if (candies[minDays] > 8)
                    {
                        totalGiven += 8;
                        currentCandy -= 8;
                        minDays++;
                    }
                    else if (currentCandy > 8)
                    {
                        totalGiven += 8;
                        currentCandy -= 8;
                        minDays++;
                    }
                    else
                    {
                        totalGiven += currentCandy;
                        currentCandy = 0;
                        minDays++;
                    }
                }

                Console.WriteLine(minDays);

        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m, r=1;
            string[] inp = Console.ReadLine().ToString().Split(' ');
            n = Convert.ToInt32(inp[0]);
            m = Convert.ToInt32(inp[1]);

            for (int i = 1; i <= n; i++)
            {
                r = (r * 3) % m;
            }

            Console.WriteLine((r-1)%m);
        }
    }
}


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

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

            long num = 1;
            for (int i = 0; i < n; i++)
                num = (num * 3);
            num = (num -1) % m;

            Console.WriteLine(num);
        }
    }
}