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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();

            long x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;

            x1 = long.Parse(line.Split(' ')[0]);
            y1 = long.Parse(line.Split(' ')[1]);
            x2 = long.Parse(line.Split(' ')[2]);
            y2 = long.Parse(line.Split(' ')[3]);

            line = Console.ReadLine();

            x3 = long.Parse(line.Split(' ')[0]);
            y3 = long.Parse(line.Split(' ')[1]);
            x4 = long.Parse(line.Split(' ')[2]);
            y4 = long.Parse(line.Split(' ')[3]);

            line = Console.ReadLine();
            x5 = long.Parse(line.Split(' ')[0]);
            y5 = long.Parse(line.Split(' ')[1]);
            x6 = long.Parse(line.Split(' ')[2]);
            y6 = long.Parse(line.Split(' ')[3]);

            long area1 = 0, area2 = 0, area3 = 0;

            if (x3 <= x1)
            {
                x3 = x1;
            }

            if (x4 >= x2)
            {
                x4 = x2;
            }

            if (y3 <= y1)
            {
                y3 = y1;
            }

            if (y4 >= y2)
            {
                y4 = y2;
            }

            if (x3 <= x4 && y3 <= y4)
            {
                area2 = (x4 - x3) * (y4 - y3);
            }

            if (x5 <= x1)
            {
                x5 = x1;
            }

            if (x6 >= x2)
            {
                x6 = x2;
            }

            if (y5 <= y1)
            {
                y5 = y1;
            }

            if (y6 >= y2)
            {
                y6 = y2;
            }

            if (x5 <= x6 && y5 <= y6)
            {
                area3 = (x6 - x5) * (y6 - y5);
            }

            var result = false;

           if (x1 == x3 && y1 == y3 && x2 == x4 && y2 == y4)
           {
                result = true;
           }
           else if (x1 == x5 && y1 == y5 && x2 == x6 && y2 == y6)
            {
                result = true;
            }
           else if (area2 == 0 || area3 == 0)
        {
                result = false;
        }
        else if (area2 > 0 && area3 > 0 &&  ((x4-x3 + x6-x5) >= (x2-x1)) && y1 == y3 && y2 == y4 && y1 == y5 && y2 == y6)
            {
                result = true;
            }
           else if (area2 > 0 && area3 > 0 && ((y4 - y3 + y6 - y5) >= (y2 - y1)) && x1 == x3 && x2 == x4 && x1 == x5 && x2 == x6)
            {
                result = true;
            }

            Console.WriteLine(!result ? "YES" : "NO");

        }

    }
}


using System;

namespace Problems
{
    class Program
    {
        static void Main(string[] args)
        {
            int x1, y1, x2, y2;

            string[] input = Console.ReadLine().Split(' ');

            x1 = Convert.ToInt32(input[0]);
            y1 = Convert.ToInt32(input[1]);
            x2 = Convert.ToInt32(input[2]);
            y2 = Convert.ToInt32(input[3]);

            int x3, y3, x4, y4;

            input = Console.ReadLine().Split(' ');

            x3 = Convert.ToInt32(input[0]);
            y3 = Convert.ToInt32(input[1]);
            x4 = Convert.ToInt32(input[2]);
            y4 = Convert.ToInt32(input[3]);

            int x5, y5, x6, y6;

            input = Console.ReadLine().Split(' ');

            x5 = Convert.ToInt32(input[0]);
            y5 = Convert.ToInt32(input[1]);
            x6 = Convert.ToInt32(input[2]);
            y6 = Convert.ToInt32(input[3]);

            bool allCovered = false;

            if(x3 <= x1 && y3 <= y1 && x4 >= x2 && y4 >= y2)
            {
                allCovered = true;
            }
            else if(x5 <= x1 && y5 <= y1 && x6 >= x2 && y6 >= y2)
            {
                allCovered = true;
            }
            else if(x3 <= x1 && y3 <= y1 && x4 < x2 && y4 >= y2)
            {
                if(x5 == x4 && y5 <= y1 && y6 >= y2 && x6 >= x2)
                {
                    allCovered = true;
                }
            }
            else if(x5 <= x1 && y5 <= y1 && x6 < x2 && y6 >= y2)
            {
                if(x3 == x6 && y3 <= y1 && y4 >= y2 && x4 >= x2)
                {
                    allCovered = true;
                }
            }
            else if(x3 <= x1 && y3 <= y1 && x4 >= x2 && y4 < y2)
            {
                if(y5 == y4 && x5 <= x1 && x6 >= x2 && y6 >= y2)
                {
                    allCovered = true;
                }
            }
            else if(x5 <= x1 && y5 <= y1 && x6 >= x2 && y6 < y2)
            {
                if(y3 == y6 && x3 <= x1 && x4 >= x2 && y4 >= y2)
                {
                    allCovered = true;
                }
            }

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


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

namespace ConsoleApp1
{
    class Program
    {
        class Rectangle
        {
            public int x1;
            public int y1;
            public int x2;
            public int y2;

            public Rectangle IntersectionRectangle(Rectangle rectangle)
            {
                if ((this.x1 >= rectangle.x2 || this.x2 <= rectangle.x1) || (this.y1 >= rectangle.y2 || this.y2 <= rectangle.y1))
                {
                    return new Rectangle();
                }
                else
                {
                    var x1 = Math.Max(this.x1, rectangle.x1);
                    var x2 = Math.Min(this.x2, rectangle.x2);

                    var y1 = Math.Max(this.y1, rectangle.y1);
                    var y2 = Math.Min(this.y2, rectangle.y2);

                    var rect = new Rectangle()
                    {
                        x1 = x1,
                        x2 = x2,
                        y1 = y1,
                        y2 = y2
                    };
                    return rect;
                }
            }

            public int Area()
            {
                return (x2 - x1) * (y2 - y1);
            }

            public static Rectangle ReadFromConsole()
            {
                var coords = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                var rect = new Rectangle()
                {
                    x1 = coords[0],
                    y1 = coords[1],
                    x2 = coords[2],
                    y2 = coords[3]
                };
                return rect;
            }
        }

        static void Main(string[] args)
        {
            var whiteRect = Rectangle.ReadFromConsole();
            var blackRect1 = Rectangle.ReadFromConsole();
            var blackRect2 = Rectangle.ReadFromConsole();

            var b1w = whiteRect.IntersectionRectangle(blackRect1);
            var b2w = whiteRect.IntersectionRectangle(blackRect2);

            var b1b2 = blackRect1.IntersectionRectangle(blackRect2);
            var b1b2w = b1b2.IntersectionRectangle(whiteRect);

            var hasWhite = (whiteRect.Area() - (b1w.Area() + b2w.Area() - b1b2w.Area()) > 0);

            Console.WriteLine(hasWhite ? "YES" : "NO");
        }

    }
}


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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			List<string> s1 = Console.ReadLine().Split(new char[] { ' ' }).ToList();
			List<string> s2 = Console.ReadLine().Split(new char[] { ' ' }).ToList();
			List<string> s3 = Console.ReadLine().Split(new char[] { ' ' }).ToList();

			int x1 = Convert.ToInt32(s1[0]), x2 = Convert.ToInt32(s1[2]), y1 = Convert.ToInt32(s1[1]), y2 = Convert.ToInt32(s1[3]);
			int x3 = Convert.ToInt32(s2[0]), x4 = Convert.ToInt32(s2[2]), y3 = Convert.ToInt32(s2[1]), y4 = Convert.ToInt32(s2[3]);
			int x5 = Convert.ToInt32(s3[0]), x6 = Convert.ToInt32(s3[2]), y5 = Convert.ToInt32(s3[1]), y6 = Convert.ToInt32(s3[3]);

			bool allPointsInside = (PointIsinside(x1, y1, x3, y3, x4, y4) || PointIsinside(x1, y1, x5, y5, x6, y6)) &&
								   (PointIsinside(x2, y2, x3, y3, x4, y4) || PointIsinside(x2, y2, x5, y5, x6, y6)) &&
								   (PointIsinside(x1, y2, x3, y3, x4, y4) || PointIsinside(x1, y2, x5, y5, x6, y6)) &&
								   (PointIsinside(x2, y1, x3, y3, x4, y4) || PointIsinside(x2, y1, x5, y5, x6, y6));

			if (!allPointsInside)
			{
				Console.WriteLine("YES");
				Console.ReadLine();
				return;
			}

			IntersectSegment(ref x1, ref x2, x3, x4);

			if (!(x1 == 0 && x2 == 0))
				IntersectSegment(ref x1, ref x2, x5, x6);

			IntersectSegment(ref y1, ref y2, y3, y4);

			if (!(y1 == 0 && y2 == 0))
				IntersectSegment(ref y1, ref y2, y5, y6);

			Console.WriteLine((x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) ? "NO" : "YES");
			Console.ReadLine();
		}

		public static bool PointIsinside(int x1, int y1, int x2, int y2, int x3, int y3)
		{
			return (x1 >= x2 && x1 <= x3 && y1 >= y2 && y1 <= y3);
		}

		public static void IntersectSegment(ref int x1, ref int x2, int x3, int x4)
		{
			if (x1 >= x3 && x1 <= x4)
			{
				if (x2 > x4)
					x1 = x4;
				else
					x1 = x2 = 0;
			} else if (x2 >= x3 && x2 <= x4)
			{
				if (x1 < x3)
					x1 = x3;
				else
					x1 = x2 = 0;
			}
		}
	}
}


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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			List<string> s1 = Console.ReadLine().Split(new char[] { ' ' }).ToList();
			List<string> s2 = Console.ReadLine().Split(new char[] { ' ' }).ToList();
			List<string> s3 = Console.ReadLine().Split(new char[] { ' ' }).ToList();

			int x1 = Convert.ToInt32(s1[0]), x2 = Convert.ToInt32(s1[2]), y1 = Convert.ToInt32(s1[1]), y2 = Convert.ToInt32(s1[3]);
			int x3 = Convert.ToInt32(s2[0]), x4 = Convert.ToInt32(s2[2]), y3 = Convert.ToInt32(s2[1]), y4 = Convert.ToInt32(s2[3]);
			int x5 = Convert.ToInt32(s3[0]), x6 = Convert.ToInt32(s3[2]), y5 = Convert.ToInt32(s3[1]), y6 = Convert.ToInt32(s3[3]);

			bool allPointsInside = (PointIsinside(x1, y1, x3, y3, x4, y4) || PointIsinside(x1, y1, x5, y5, x6, y6)) &&
								   (PointIsinside(x2, y2, x3, y3, x4, y4) || PointIsinside(x2, y2, x5, y5, x6, y6)) &&
								   (PointIsinside(x1, y2, x3, y3, x4, y4) || PointIsinside(x1, y2, x5, y5, x6, y6)) &&
								   (PointIsinside(x2, y1, x3, y3, x4, y4) || PointIsinside(x2, y1, x5, y5, x6, y6));

			if (!allPointsInside)
			{
				Console.WriteLine(!(x1 == x2 && x1 == y1 && x1 == y2) ? "YES" : "NO");
				Console.ReadLine();
				return;
			}

			IntersectSegment(ref x1, ref x2, x3, x4);

			if (!(x1 == 0 && x2 == 0))
				IntersectSegment(ref x1, ref x2, x5, x6);

			IntersectSegment(ref y1, ref y2, y3, y4);

			if (!(y1 == 0 && y2 == 0))
				IntersectSegment(ref y1, ref y2, y5, y6);

			Console.WriteLine((x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) ? "NO" : "YES");
			Console.ReadLine();
		}

		public static bool PointIsinside(int x1, int y1, int x2, int y2, int x3, int y3)
		{
			return (x1 >= x2 && x1 <= x3 && y1 >= y2 && y1 <= y3);
		}

		public static void IntersectSegment(ref int x1, ref int x2, int x3, int x4)
		{
			if (x1 >= x3 && x1 <= x4)
			{
				if (x2 > x4)
					x1 = x4;
				else
					x1 = x2 = 0;
			} else if (x2 >= x3 && x2 <= x4)
			{
				if (x1 < x3)
					x1 = x3;
				else
					x1 = x2 = 0;
			}
		}
	}
}


using System;

namespace CF587.C
{
    public class Rectangle
    {
        public int MinX { get; set; }
        public int MinY { get; set; }

        public int MaxX { get; set; }
        public int MaxY { get; set; }
    }

    public enum OverlapType
    {
        Partial,
        Full,
        No,
        Right,
        Top,
        Left,
        Bottom,
    }

    public class Program
    {
        public static OverlapType GetOverlapType(Rectangle r1, Rectangle r2)
        {
            if (r2.MinX > r1.MaxX || r2.MaxX < r1.MinX) return OverlapType.No;
            if (r2.MinY > r1.MaxY || r2.MaxY < r1.MinY) return OverlapType.No;
            if (r2.MinX <= r1.MinX && r2.MaxX >= r1.MaxX && r2.MinY <= r1.MinY && r2.MaxY >= r1.MaxY) return OverlapType.Full;
            if (r2.MinX <= r1.MinX && r2.MaxX >= r1.MaxX && r2.MinY <= r1.MinY && r2.MaxY < r1.MaxY) return OverlapType.Bottom;
            if (r2.MinX <= r1.MinX && r2.MaxX >= r1.MaxX && r2.MinY > r1.MinY && r2.MaxY >= r1.MaxY) return OverlapType.Top;
            if (r2.MinX <= r1.MinX && r2.MaxX < r1.MaxX && r2.MinY <= r1.MinY && r2.MaxY >= r1.MaxY) return OverlapType.Left;
            if (r2.MinX > r1.MinX && r2.MaxX >= r1.MaxX && r2.MinY <= r1.MinY && r2.MaxY >= r1.MaxY) return OverlapType.Right;
            return OverlapType.Partial;
        }

        public static void Main(string[] args)
        {
            var firstStr = Console.ReadLine()?.Split(' ') ?? throw new ArgumentNullException();
            var secondStr = Console.ReadLine()?.Split(' ') ?? throw new ArgumentNullException();
            var thirdStr = Console.ReadLine()?.Split(' ') ?? throw new ArgumentNullException();

            var white = new Rectangle
            {
                MinX = int.Parse(firstStr[0]),
                MinY = int.Parse(firstStr[1]),
                MaxX = int.Parse(firstStr[2]),
                MaxY = int.Parse(firstStr[3]),
            };

            var b1 = new Rectangle
            {
                MinX = int.Parse(secondStr[0]),
                MinY = int.Parse(secondStr[1]),
                MaxX = int.Parse(secondStr[2]),
                MaxY = int.Parse(secondStr[3]),
            };

            var b2 = new Rectangle
            {
                MinX = int.Parse(thirdStr[0]),
                MinY = int.Parse(thirdStr[1]),
                MaxX = int.Parse(thirdStr[2]),
                MaxY = int.Parse(thirdStr[3]),
            };

            var firstOverlap = GetOverlapType(white, b1);
            var secondOverlap = GetOverlapType(white, b2);

            var result = "YES";
            switch (firstOverlap)
            {
                case OverlapType.Full:
                    result = "NO";
                    break;

                case OverlapType.No:
                case OverlapType.Partial:
                    if (secondOverlap == OverlapType.Full) result = "NO";
                    break;

                case OverlapType.Right:
                    if (secondOverlap == OverlapType.Full) result = "NO";
                    if (secondOverlap == OverlapType.Left && b2.MaxX >= b1.MinY) result = "NO";
                    break;

                case OverlapType.Top:
                    if (secondOverlap == OverlapType.Full) result = "NO";
                    if (secondOverlap == OverlapType.Bottom && b2.MaxY >= b1.MinY) result = "NO";
                    break;

                case OverlapType.Left:
                    if (secondOverlap == OverlapType.Full) result = "NO";
                    if (secondOverlap == OverlapType.Right && b1.MaxX >= b2.MinX) result = "NO";
                    break;

                case OverlapType.Bottom:
                    if (secondOverlap == OverlapType.Full) result = "NO";
                    if (secondOverlap == OverlapType.Top && b1.MaxY >= b2.MinY) result = "NO";
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            Console.WriteLine(result);
        }
    }
}


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

namespace ConsoleApplication1
{
  class Program
  {

    static char[][] nums;
    static int k, n, ans;

    static void gen(int l, int r)
    {
      if (l==r)
      {
        int min = int.MaxValue;
        int max = int.MinValue;
        for (int num = 0; num < n; num++)
        {
          if (int.Parse(new string(nums[num])) > max)
            max = int.Parse(new string(nums[num]));

          if (int.Parse(new string(nums[num])) < min)
            min = int.Parse(new string(nums[num]));
        }

        ans = Math.Min(ans, max - min);
      }
      else
      {
        for (int i = l; i <= r; i++)
        {
          for (int num = 0; num < n; num++)
          {
            char tmp = nums[num][l];
            nums[num][l] = nums[num][i];
            nums[num][i] = tmp;
          }
          gen(l + 1, r);
          for (int num = 0; num < n; num++)
          {
            char tmp = nums[num][l];
            nums[num][l] = nums[num][i];
            nums[num][i] = tmp;
          }

        }
      }
    }

    static void Main(string[] args)
    {
      string[] strarr = Console.ReadLine().Split(' ');
      n = int.Parse(strarr[0]);
      k = int.Parse(strarr[1]);

      nums = new char[n][];
      for (int i = 0; i < n; i++)
        nums[i] = Console.ReadLine().ToCharArray();

      ans = int.MaxValue;
      gen(0, k - 1);
      Console.WriteLine(ans);

    }
  }
}


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

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

        private static void Main(string[] args)
        {
            int n = Next();
            int k = Next();

            var nn = new int[n][];
            for (int i = 0; i < nn.Length; i++)
            {
                nn[i] = new int[k];
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < k; j++)
                {
                    nn[i][j] = Next();
                }
            }

            var perm = new int[k];
            for (int i = 0; i < k; i++)
            {
                perm[i] = i;
            }

            int min = int.MaxValue;

            do
            {
                int mi = int.MaxValue;
                int ma = int.MinValue;

                for (int i = 0; i < n; i++)
                {
                    int sum = 0;
                    for (int j = 0; j < k; j++)
                    {
                        sum = sum*10 + nn[i][perm[j]];
                    }
                    mi = Math.Min(mi, sum);
                    ma = Math.Max(ma, sum);
                }

                min = Math.Min(min, ma - mi);
            } while (NextPermutation(perm));

            writer.WriteLine(min);
            writer.Flush();
        }

        private static bool NextPermutation(int[] nn)
        {
            if (nn.Length <= 1) return false;
            int i = nn.Length - 1;
            int last = nn.Length;

            while (true)
            {
                int i1 = i;
                if (nn[--i] < nn[i1])
                {
                    int i2 = last;
                    while (!(nn[i] < nn[--i2]))
                    {
                        ;
                    }
                    int c = nn[i];
                    nn[i] = nn[i2];
                    nn[i2] = c;

                    Reverse(nn, i1, last);
                    return true;
                }
                if (i == 0)
                {
                    Reverse(nn, 0, last);
                    return false;
                }
            }
        }

        private static void Reverse(int[] nn, int first, int last)
        {
            while ((first != last) && (first != --last))
            {
                int c = nn[first];
                nn[first] = nn[last];
                nn[last] = c;
                first++;
            }
        }

        private static int Next()
        {
            int c;
            do
            {
                c = reader.Read();
            } while (c < '0' || c > '9');
            return c - '0';
        }
    }
}


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

namespace _Permutations
{
    class ProgramPermutations
    {
        public static int[] Digits(int num)
        {
            var d = new Stack<int>();
            if (num == 0) d.Push(0);

            while (num > 0)
            {
                d.Push(num % 10);
                num /= 10;
            }

            return d.ToArray();
        }

        public static int DigitsToNum(int[] digits)
        {
            var result = 0;
            var mult = 1;
            for (var i = digits.Length - 1; i >= 0; i--)
            {
                result += digits[i] * mult;
                mult *= 10;
            }

            return result;
        }

        static IEnumerable<int[]> GetPerms(List<int> seq)
        {
            seq.Sort();
            var len = seq.Count();
            var n = len - 1;
            var lst = new List<int[]> {seq.ToArray()};

            while (true)
            {
                var k = -1;
                for (var i = 0; i < n; i++)
                {
                    if (seq[i] < seq[i + 1]) k = i;
                }
                if (k == -1) break;
                var l = -1;
                for (var i = 0; i < len; i++)
                {
                    if (seq[k] < seq[i]) l = i;
                }
                var temp = seq[k];
                seq[k] = seq[l];
                seq[l] = temp;

                var seqNext = new int[len];
                for (var i = 0; i <= k; i++)
                {
                    seqNext[i] = seq[i];
                }
                for (var i = n; i > k; i--)
                {
                    seqNext[k + len - i] = seq[i];
                }
                lst.Add(seqNext);
                seq = new List<int>(seqNext);
                //Console.WriteLine(DigitsToNum(seqNext));
            }

            return lst;
        }

        static bool GreaterThan(IList<int> num1, IList<int> num2, int k)
        {
            for (var i = 0; i < k; i++)
            {
                if (num1[i] < num2[i]) return false;
                if (num1[i] > num2[i]) return true;
            }
            return false;
        }

        static bool LessThan(IList<int> num1, IList<int> num2, int k)
        {
            for (var i=0; i<k; i++)
            {
                if (num1[i] > num2[i]) return false;
                if (num1[i] < num2[i]) return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            if (args.Count() > 0)
            {
                var r = new Random(1021);

                Console.WriteLine("{0} {1}", args[0], args[1]);
                for (var i=0; i<int.Parse(args[0]); i++)
                {
                    for (var j=0; j<int.Parse(args[1]); j++)
                    {
                        Console.Write(r.Next(0, 10));
                    }
                    Console.WriteLine();
                }

                return;
            }

            var strParams = Console.ReadLine();
            if (string.IsNullOrEmpty(strParams)) return;
            var strnk = strParams.Split();
            var n = int.Parse(strnk[0]);
            var k = int.Parse(strnk[1]);
            var nums = new List<List<int>>();
            for (var i = 0; i < n; i++)
            {
                var strNum = Console.ReadLine();
                if (string.IsNullOrEmpty(strNum)) return;
                var num = strNum.Select(c => c - 48).ToList();
                nums.Add(num);
            }

            // Numbers from 0..k-1 in order
            var seq = new List<int>();
            for (var i=0; i<k; i++)
            {
                seq.Add(i);
            }

            // Permute them
            var permsTemplate = GetPerms(seq);

/*
            foreach (var intse in permsTemplate)
            {
                Console.WriteLine(DigitsToNum(intse));
            }
            return;
*/

            var minDifference = Int32.MaxValue;
            foreach (var perm in permsTemplate)
            {
                // Permute each input number according to the same permutation rule
                //var maxNum = Int32.MinValue;
                //var minNum = Int32.MaxValue;
                var maxNum = new List<int>();
                var minNum = new List<int>();
                for (var i = 0; i < k; i++)
                {
                    maxNum.Add(0);
                    minNum.Add(9);
                }

                foreach (var i in nums)
                {
                    var permDigits = new int[k];
                    for (var j = 0; j < k; j++)
                    {
                        permDigits[j] = i[perm[j]];
                    }
                    if (GreaterThan(permDigits, maxNum, k)) maxNum = new List<int>(permDigits);
                    if (LessThan(permDigits, minNum, k)) minNum = new List<int>(permDigits);
                    //var newNum = DigitsToNum(permDigits);
                    //if (newNum > maxNum) maxNum = newNum;
                    //if (newNum < minNum) minNum = newNum;
                }
                var diff = DigitsToNum(maxNum.ToArray()) - DigitsToNum(minNum.ToArray());
                //Console.WriteLine("{0} - {1} = {2}", DigitsToNum(maxNum.ToArray()), DigitsToNum(minNum.ToArray()), diff);
                if (diff < minDifference) minDifference = diff;
            }
            Console.WriteLine(minDifference);
        }
    }
}


using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Console;

namespace CodeForces
{
    public class Program
    {
        static void Main()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Solve(In, Out);
            PrintTime(stopwatch);
        }
        public static void Solve(TextReader In, TextWriter Out)
        {
            int[] input = In.ReadLine().Split().Select(str => int.Parse(str)).ToArray();
            int N = input[0], m = input[1];

            int[] f = new int[N * 2 + 1];
            f[N] = 1;
            for (long n = N - 1; n > 0; n--)
            {
                f[n] = 2 * f[n + 1] % m;
                for (int i = 2; i <= N / n; i++)
                {
                    f[n] = (f[n] + f[i * n] - f[(n + 1) * i]) % m;
                    if (f[n] < 0)
                    {
                        f[n] += m;
                    }
                }
            }
            int res = (f[1] - f[2]) % m;
            if (res < 0)
            {
                res += m;
            }

            Out.WriteLine(res);
        }

        [Conditional("DEBUG")]
        internal static void PrintTime(Stopwatch stopwatch) => WriteLine(stopwatch.Elapsed);
    }
}


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

class cf740
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, key) = (c[0], c[1]);
        var suball = 0L;
        var dp = new long[n + 1];
        dp[n] = 1;
        for (var i = n; i > 1; --i)
        {
            var val = (dp[i] + suball) % key;
            suball = (suball + val) % key;
            var last = i;
            for (var j = 2; j * j <= i; ++j)
            {
                dp[i / j] = (dp[i / j] + val) % key;
                last = i / j;
            }
            var sub = 0;
            for (var j = 1; j < last; ++j)
            {
                var mul = i - i / (j + 1) - sub;
                dp[j] = (dp[j] + val * mul) % key;
                sub += mul;
            }
        }
        WriteLine((dp[1] + suball) % key);
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solution
{
    public void Solve()
    {
        int n = ReadInt();
        int mod = ReadInt();

        var dp = new long[n + 1];
        dp[1] = 1;
        long sum = 1;
        for (int i = 2; i <= n; i++)
        {
            dp[i] = sum;
            int j;
            for (j = 2; j * j <= i; j++)
                dp[i] = (dp[i] + dp[i / j]) % mod;
            int p = j - 1;
            for (j = i / j; j > 0; j--)
            {
                int o = i / j;
                dp[i] = (dp[i] + (o - p) * dp[j]) % mod;
                p = o;
            }
            sum = (sum + dp[i]) % mod;
        }

        Write(dp[n]);
    }

    #region Main

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

    #endregion

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


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

namespace CodeForces
{
    public class Program
    {
        static void Main()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Solve(In, Out);
            PrintTime(stopwatch);
        }
        public static void Solve(TextReader In, TextWriter Out)
        {
            int[] input = In.ReadLine().Split().Select(str => int.Parse(str)).ToArray();
            int N = input[0], m = input[1];

            int[] sum = new int[N + 1];
            int[] links = new int[N];
            for (int n = 2; n <= N; n++)
            {
                Array.Fill(links, 1, 1, n - 1);
                sum[1] = 1;
                for (int i = 2; i <= n; i++)
                {
                    links[n / i]++;
                }
                for (int i = 1; i < n; i++)
                {
                    sum[n] = (int)((sum[n] + (sum[i] * ((long)links[i]))) % m);
                }
            }

            Out.WriteLine(sum[N]);
        }

        [Conditional("DEBUG")]
        internal static void PrintTime(Stopwatch stopwatch) => WriteLine(stopwatch.Elapsed);
    }
}


using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Console;

namespace CodeForces
{
    public class Program
    {
        static void Main()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Solve(In, Out);
            PrintTime(stopwatch);
        }
        public static void Solve(TextReader In, TextWriter Out)
        {
            int[] input = In.ReadLine().Split().Select(str => int.Parse(str)).ToArray();
            int n = input[0], m = input[1];

            int[] f = new int[n + 1];
            f[n] = 1;
            for (; n > 1; n--)
            {
                int[] f1 = new int[n]; //f.Take(n).ToArray();
                f1[1] = f[1];
                int[] sum = new int[n + 1];
                for (int i = n; i > 1; i--)
                {
                    sum[i - 1] = (sum[i] + f[i]) % m;
                }
                for (int x = n; x > 1; x--)
                {
                    f1[x - 1] = (f1[x - 1] + sum[x - 1]) % m;
                    for (int i = 2; i <= x;)
                    {
                        int index = x / i;
                        int maxIndex = x / index;
                        int count = maxIndex - i + 1;
                        f1[index] = (int)((f1[index] + ((long)count * f[x])) % m);
                        i += count;
                    }
                    //for (int i = 1; i <= x; i++)
                    //{
                    //    int index = x / (i + 1);
                    //    f1[x - i] = (f1[x - i] + f[x]) % m;
                    //    f1[index] = (f1[index] + f[x]) % m;
                    //}
                }
                f = f1;
            }
            Out.WriteLine(f[1]);
        }

        [Conditional("DEBUG")]
        internal static void PrintTime(Stopwatch stopwatch) => WriteLine(stopwatch.Elapsed);
    }
}


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

namespace CodeForces
{
    public class CodeForcesClass
    {
        public static bool IsPointIn(Point p, int n)
        {
            var d = Math.Sqrt(p.X * p.X + p.Y * p.Y);
            if (Math.Abs(d - n) < 1e-6 || d < n)
            {
                return true;
            }
            return false;
        }

        public static void Main()
        {
            var n = Read<int>();
            var full = Math.Sqrt(3);
            var half = full / 2;
            var points = new[]
            {
                new Point {X = 0.5, Y = half}, new Point {X = 1, Y = 0}
            };

            long h = 0;
            var current = new Point[2];
            for (var i = 0; i < 2; i++)
            {
                current[i] = points[i];
            }
            while (current.All(x => IsPointIn(x, n)))
            {
                h++;
                for (var i = 0; i < 2; i++)
                {
                    current[i].Y += full;
                }
            }
            var temp = new Point[2];
            long count = h + h - 1;
            var moved = 1;
            while (true)
            {
                for (var i = 0; i < 2; i++)
                {
                    current[i] = points[i];
                    current[i].X += moved * 1.5;
                }
                if (moved % 2 == 1)
                {
                    for (var i = 0; i < 2; i++)
                    {
                        current[i].Y -= half;
                    }
                }
                var start = h + 1;
                while (start >= 0)
                {

                    for (var i = 0; i < 2; i++)
                    {
                        temp[i] = current[i];
                        temp[i].Y += start * full;
                    }
                    if (temp.All(x => IsPointIn(x, n)))
                    {
                        break;
                    }
                    start--;
                }
                h = start;
                if (h == -1)
                {
                    break;
                }
                if (moved % 2 == 1)
                {
                    count += h * 4;
                }
                if (moved % 2 != 1)
                {
                    count += (h + h + 1) * 2;
                }
                moved++;
            }
            Console.WriteLine(count);
        }

        public struct Point
        {
            public double X { get; set; }
            public double Y { get; set; }
        }

        // Here goes misc

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

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

        public static List<T> ReadListNlines<T>(int n, char[] delimiters = null)
        {
            var list = new List<T>();
            for (var i = 0; i < n; i++)
            {
                list.Add(Read<T>());
            }
            return list;
        }

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

        public static bool NextPermutation<T>(T[] items) where T : IComparable
        {
            var i = -1;
            for (var x = items.Length - 2; x >= 0; x--)
            {
                if (items[x].CompareTo(items[x + 1]) < 0)
                {
                    i = x;
                    break;
                }
            }

            if (i == -1)
            {
                return false;
            }
            var j = 0;
            for (var x = items.Length - 1; x > i; x--)
            {
                if (items[x].CompareTo(items[i]) > 0)
                {
                    j = x;
                    break;
                }
            }
            var temp = items[i];
            items[i] = items[j];
            items[j] = temp;
            Array.Reverse(items, i + 1, items.Length - (i + 1));
            return true;
        }

        public static string ReplaceChar(string str, char c, int idx)
        {
            return str.Substring(0, idx) + c + str.Substring(idx + 1);
        }
    }
}


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

namespace CodeForces
{
    public class CodeForcesClass
    {
        public static bool IsPointIn(Point p, int n)
        {
            var d = Math.Sqrt(p.X*p.X + p.Y*p.Y);
            if (Math.Abs(d - n) < 1e-6 || d < n)
            {
                return true;
            }
            return false;
        }

        public static void Main()
        {
            var n = Read<int>();
            var full = Math.Sqrt(3);
            var half = full/2;
            var points = new[]
            {
                new Point {X = -0.5, Y = half}, new Point {X = 0.5, Y = half}, new Point {X = 1, Y = 0},
                new Point {X = 0.5, Y = -half}, new Point {X = -0.5, Y = -half}, new Point {X = -1, Y = 0}
            };

            long h = 0;
            var current = new Point[6];
            for (var i = 0; i < 6; i++)
            {
                current[i] = points[i];
            }
            while (current.All(x => IsPointIn(x, n)))
            {
                h++;
                for(var i = 0; i < 6; i++)
                {
                    current[i].Y += full;
                }
            }
            var temp = new Point[6];
            long count = h + h - 1;
            var moved = 1;
            while (true)
            {
                for (var i = 0; i < 6; i++)
                {
                    current[i] = points[i];
                    current[i].X += moved*1.5;
                }
                if (moved % 2 == 1)
                {
                    for (var i = 0 ; i < 6; i++)
                    {
                        current[i].Y -= half;
                    }
                }
                var start = h + 3;
                while (start >= 0)
                {

                    for (var i = 0; i < 6; i++)
                    {
                        temp[i] = current[i];
                        temp[i].Y += start*full;
                    }
                    if (temp.All(x => IsPointIn(x, n)))
                    {
                        break;
                    }
                    start--;
                }
                h = start;
                if (h == -1)
                {
                    break;
                }
                if (moved % 2 == 1)
                {
                    count += h*4;
                }
                if (moved % 2 != 1)
                {
                    count += (h + h + 1) * 2;
                }
                moved++;
            }
            Console.WriteLine(count);
        }

        public struct Point
        {
            public double X { get; set; }
            public double Y { get; set; }
        }

        // Here goes misc

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

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

        public static List<T> ReadListNlines<T>(int n, char[] delimiters = null)
        {
            var list = new List<T>();
            for (var i = 0; i < n; i++)
            {
                list.Add(Read<T>());
            }
            return list;
        }

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

        public static bool NextPermutation<T>(T[] items) where T : IComparable
        {
            var i = -1;
            for (var x = items.Length - 2; x >= 0; x--)
            {
                if (items[x].CompareTo(items[x + 1]) < 0)
                {
                    i = x;
                    break;
                }
            }

            if (i == -1)
            {
                return false;
            }
            var j = 0;
            for (var x = items.Length - 1; x > i; x--)
            {
                if (items[x].CompareTo(items[i]) > 0)
                {
                    j = x;
                    break;
                }
            }
            var temp = items[i];
            items[i] = items[j];
            items[j] = temp;
            Array.Reverse(items, i + 1, items.Length - (i + 1));
            return true;
        }

        public static string ReplaceChar(string str, char c, int idx)
        {
            return str.Substring(0, idx) + c + str.Substring(idx + 1);
        }
    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        const double eps = 0.01;

        static int dcmp(double x)
        {
            if (x < -eps) return -1;
            if (x > eps) return 1;
            return 0;
        }

        static void Main(string[] args)
        {
            Int64 data = Int64.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            Int64 n = (Int64)((Math.Sqrt((((double)data * data) - 0.5 * 0.5) / 0.75) + 1) / 2);
            count=3*n*n-3*n+1;

                Int64 need = 0;
                Int64 j = 0;
                do
                {
                    double yy = ( 0.5+n ) * Math.Sqrt(3);
                    double xx = 0.5;
                    need = 0;
                    for (Int64 i = j; i < (n + 1)/2+2; i++)
                    {
                        double x = xx + 1.5 * i;
                        double y = yy - (double)i * Math.Sqrt(3)/2;
                        if (dcmp(x * x + y * y - (double)(data) * data) <= 0)
                        {
                            need = (n + 1 - i * 2) < 0 ? 0 : (n + 1 - i * 2);
                            j = i;
                            break;
                        }
                    }
                    count += need * 6;
                    n++;
                } while (need != 0);

            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            Int64 n = (Int64)((Math.Sqrt((((double)data * data) - 0.5 * 0.5) / 0.75) + 1) / 2);
            count=3*n*n-3*n+1;

                Int64 need = 0;
                int j = 0;
                do
                {
                    double yy = (n + 0.5) * Math.Sqrt(3);
                    double xx = 0.5;
                    need = 0;
                    for (int i = j; i < n + 1; i++)
                    {
                        double x = xx + 1.5 * i;
                        double y = yy - (double)i * Math.Sqrt(3)/2;
                        if (x * x + y * y - (double)data * data<10e-6)
                        {
                            need = (n + 1 - i * 2) < 0 ? 0 : (n + 1 - i * 2);
                            j = i;
                            break;
                        }
                    }
                    count += need * 6;
                    n++;
                } while (need != 0);

            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            int n = (int)((Math.Sqrt(((double)(data * data) - 0.5 * 0.5) / 0.75) + 1) / 2);
            count=3*n*n-3*n+1;

                Int64 need = 0;
                do
                {
                    double yy = (n + 0.5) * Math.Sqrt(3);
                    double xx = 0.5;
                    need = 0;
                    for (int i = 0; i < n + 1; i++)
                    {
                        double x = xx + 1.5 * i;
                        double y = yy - (double)i * Math.Sqrt(3)/2;
                        if (x * x + y * y - (double)data * data<10e-6)
                        {
                            need = (n + 1 - i * 2) < 0 ? 0 : (n + 1 - i * 2);
                            break;
                        }
                    }
                    count += need * 6;
                    n++;
                } while (need != 0);

            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            Int64 count = 0;
            int n = (data-1)/2+1;
            count=3*n*n-3*n+1;
            if (data % 2 == 0)
            {
                double yy = (n + 0.5) * Math.Sqrt(3);
                double xx = 0.5;
                int need = 0;
                for (int i = 0; i < n+2; i++)
                {
                    double x = xx + 1.5 * i;
                    double y = yy - i;
                    if (x * x + y * y <= (double)data * data)
                    {
                        need = (n + 1 - i* 2) < 0 ? 0 : (n + 1 - i * 2);
                    }
                }
                count += need * 6;
            }
            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            Int64 count = 0;
            int n = (data-1)/2+1;
            count=3*n*n-3*n+1;
            if (data % 2 == 0)
            {
                count += (n - 1) * 6;
            }
            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            int n = (data-1)/2+1;
            count=3*n*n-3*n+1;
            if (data % 2 == 0)
            {
                double yy = (n + 0.5) * Math.Sqrt(3);
                double xx = 0.5;
                int need = 0;
                for (int i = 0; i < n+2; i++)
                {
                    double x = xx + 1.5 * i;
                    double y = yy - i;
                    if (x * x + y * y <= (double)data * data)
                    {
                        need = (n + 1 - i* 2) < 0 ? 0 : (n + 1 - i * 2);
                        break;
                    }
                }
                count += need * 6;
            }
            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            int n = (data-1)/2+1;
            count=3*n*n-3*n+1;
            if (data % 2 == 0)
            {
                double yy = (n + 0.5) * Math.Sqrt(3);
                double xx = 0.5;
                int need = 0;
                for (int i = 0; i < n+2; i++)
                {
                    double x = xx + 1.5 * i;
                    double y = yy - i;
                    if (x * x + y * y <= (double)data * data)
                    {
                        need = (n + 1 - i* 2) < 0 ? 0 : (n + 1 - i * 2);
                    }
                }
                count += need * 6;
            }
            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            int n = (int)((Math.Sqrt(((double)(data * data) - 0.5 * 0.5) / 0.75) + 1) / 2);
            count=3*n*n-3*n+1;

                int need = 0;
                do
                {
                    double yy = (n + 0.5) * Math.Sqrt(3);
                    double xx = 0.5;
                    need = 0;
                    for (int i = 0; i < n + 1; i++)
                    {
                        double x = xx + 1.5 * i;
                        double y = yy - i * Math.Sqrt(3)/2;
                        if (x * x + y * y <= (double)data * data)
                        {
                            need = (n + 1 - i * 2) < 0 ? 0 : (n + 1 - i * 2);
                            break;
                        }
                    }
                    count += need * 6;
                    n++;
                } while (need != 0);

            Console.WriteLine(count);

        }

    }
}


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

namespace A.Theatre_Square
{
    class Program
    {

        static void Main(string[] args)
        {
            int data = Int32.Parse(Console.ReadLine().Trim());
            if (data == 0)
            {
                Console.WriteLine("0");
                return;
            }
            Int64 count = 0;
            int n = (data-1)/2+1;
            count=3*n*n-3*n+1;

                int need = 0;
                do
                {
                    double yy = (n + 0.5) * Math.Sqrt(3);
                    double xx = 0.5;
                    need = 0;
                    for (int i = 0; i < n + 2; i++)
                    {
                        double x = xx + 1.5 * i;
                        double y = yy - i;
                        if (x * x + y * y <= (double)data * data)
                        {
                            need = (n + 1 - i * 2) < 0 ? 0 : (n + 1 - i * 2);
                            break;
                        }
                    }
                    count += need * 6;
                    n++;
                } while (need != 0);

            Console.WriteLine(count);

        }

    }
}


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

namespace CF {
	class Program {

		static void Main(string[] args) {

#if DEBUG
			TextReader reader = new StreamReader("../../input.txt");

#else
			TextReader reader = Console.In;
#endif

			int[] l1 = reader.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			int[] l2 = reader.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

			int a = l1[0], b = l1[1], m = l1[2];
			int vx = l2[0], vy = l2[1], vz = l2[2];

			double time = m * 1.0 / -vy;

			//double zdist = vz * time;

			double xpos = a * 1.0 / 2 + vx * time;
			xpos = xpos - 2 * a * Math.Floor(xpos / (2 * a));
			if (xpos > a) {
				xpos = 2 * a - xpos;
			}

			//Console.WriteLine(xpos);

			double zpos = vz * time;
			zpos = zpos - 2 * b * Math.Floor(zpos / (2 * b));
			if (zpos > b) {
				zpos = 2 * b - zpos;
			}

			string answ = xpos + " " + zpos;

			Console.WriteLine(answ.Replace(",", "."));

#if DEBUG
			Console.ReadKey();
#endif

		}

	}
}


//

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

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

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

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

    public class Program
    {
        #region Helpers

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        static void pe() { Console.WriteLine("???"); Environment.Exit(0); }
        static void re() { Environment.Exit(55); }
        static void Swap<T>(ref T a, ref T b) { T t = a; a = b; b = t; }
        static int Sqr(int a) { return a * a; }
        static long SqrL(int a) { return (long)a * a; }
        static long Sqr(long a) { return a * a; }
        static double Sqr(double a) { return a * a; }

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

        #endregion Helpers

        static void Main(string[] args)
        {
            checked
            {
                //Console.SetIn(File.OpenText("_input"));
                var parser = new Parser();
                while (!parser.SeekEOF)
                {
                    double a = parser.ReadDouble();
                    double b = parser.ReadDouble();
                    double m = parser.ReadDouble();
                    double vx = parser.ReadDouble();
                    double vy = parser.ReadDouble();
                    double vz = parser.ReadDouble();

                    double t = m / -vy;
                    double t_bak = t;

                    /* x result */
                    double x = a / 2;
                    if (vx != 0)
                    {
                        while (t > 0)
                        {
                            if (vx < 0)
                            {
                                double tt = x / -vx;
                                if (t <= tt)
                                {
                                    x += t * vx;
                                    break;
                                }
                                else
                                {
                                    x = 0;
                                    vx = -vx;
                                    t -= tt;
                                }
                            }
                            else
                            {
                                double tt = (a - x) / vx;
                                if (t <= tt)
                                {
                                    x += t * vx;
                                    break;
                                }
                                else
                                {
                                    x = a;
                                    vx = -vx;
                                    t -= tt;
                                }
                            }
                        }
                    }

                    /* z result */
                    t = t_bak;
                    double z = 0;
                    if (vz != 0)
                    {
                        while (t > 0)
                        {
                            if (vz < 0)
                            {
                                double tt = z / -vz;
                                if (t <= tt)
                                {
                                    z += t * vz;
                                    break;
                                }
                                else
                                {
                                    z = 0;
                                    vz = -vz;
                                    t -= tt;
                                }
                            }
                            else
                            {
                                double tt = (b - z) / vz;
                                if (t <= tt)
                                {
                                    z += t * vz;
                                    break;
                                }
                                else
                                {
                                    z = b;
                                    vz = -vz;
                                    t -= tt;
                                }
                            }
                        }
                    }

                    Console.WriteLine(x.AsString(10) + " " + z.AsString(10));
                }
            }
        }

        //static void Main(string[] args)
        //{
        //    new Thread(Main2, 50 << 20).Start();
        //}
    }
}


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

public class taskD
{
    static void Main(string[] args)
    {
        string inp = Console.ReadLine();
        string[] spl = inp.Split(' ');

        int a, b, m;
        a = int.Parse(spl[0]);
        b = int.Parse(spl[1]);
        m = int.Parse(spl[2]);

        inp = Console.ReadLine();
        spl = inp.Split(' ');

        int vx, vy, vz;
        vx = int.Parse(spl[0]);
        vy = int.Parse(spl[1]);
        vz = int.Parse(spl[2]);

        double t = -(double)m / vy;

        double x0 = (double)a / 2.0 + t * (double)vx;
        double z0 = t * (double)vz;

        bool invx = false;
        bool invz = false;

        while (x0 > a)
        {
            x0 -= a;
            invx = !invx;
        }
        while (x0 < 0)
        {
            x0 += a;
            invx = !invx;
        }
        while (z0 > b)
        {
            z0 -= b;
            invz = !invz;
        }
        while (z0 < 0)
        {
            z0 += b;
            invz = !invz;
        }

        if (invx) x0 = a - x0;
        if (invz) z0 = b - z0;

        System.Globalization.NumberFormatInfo ni = new System.Globalization.NumberFormatInfo();
        ni.NumberDecimalSeparator = ".";

        Console.WriteLine("{0} {1}", x0.ToString(ni), z0.ToString(ni));
    }

}


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

namespace CodeForces {
    struct Node {
        public int X, Y, D;
        public Node(int x,int y, int d) {
            X = x;
            Y = y;
            D = d;
        }
    }

    class Pair : IComparable<Pair> {
        public int First, Second;
        public Pair(int f, int s) {
            First = f;
            Second = s;
        }

        public int CompareTo(Pair other) {
            return Second.CompareTo(other.Second);
        }
    }

    class Desc : IComparer<int> {
        public int Compare(int x, int y) {
            return y.CompareTo(x);
        }
    }

    class Cf {
        static TextReader input;
        static void Main(string[] args) {
#if TESTS
            Stopwatch sw = new Stopwatch();
            sw.Start();
            input = new StreamReader("input.txt");
#else
            input = Console.In;
#endif
            Solve();
#if TESTS
            Console.WriteLine();
            Console.WriteLine("Milliseconds: {0}", sw.ElapsedMilliseconds);
            Console.ReadLine();
#endif
        }

        const int MOD = 1000000007;
        static int n, m;
        static void Solve() {
            int[] arr = ReadIntArray();
            double[] v = ReadDoubleArray();
            int a = arr[0];
            int b = arr[1];
            m = arr[2];
            double[] u = new double[3];
            u[0] = a;
            u[2] = b;
            double[] d = new double[3];
            d[0] = ((double)a) / 2;
            d[1] = (double)m;
            d[2] = 0;
            double x0 = 0;
            double z0 = 0;
            while (true) {
                List<int> minl = new List<int>();
                int min = -1;
                double mint = double.MaxValue;
                for (int i = 0; i < 3; i++) {
                    double ti = 0;
                    if (v[i] == 0) continue;
                    else if (v[i] > 0)
                        ti = (u[i] - d[i]) / v[i];
                    else
                        ti = -d[i] / v[i];
                    if (ti < mint) {
                        minl.Clear();
                        min = i;
                        mint = ti;
                        minl.Add(i);
                    }
                    else if (ti == mint) {
                        minl.Add(i);
                    }
                }
                for (int i = 0; i < 3; i++) {
                    d[i] += mint * v[i];
                }
                foreach (int item in minl) {
                    v[item] = -v[item];
                }
                if (d[1] == 0) {
                    x0 = d[0];
                    z0 = d[2];
                    break;
                }
            }
            string res = string.Format("{0} {1}",x0,z0).Replace(',','.');
            Console.WriteLine(res);
        }

        #region math
        static long gcd(long a, long b) {
            return b != 0 ? gcd(b, a % b) : a;
        }

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

        //static int SquaredDistanceBetweenSegments(int x1, int y1, int x2, int y2, int xx1, int yy1, int xx2, int yy2) {
        //    return Math.Min(Math.Min(SquaredDistanceToSegment(x1, y1, xx1, yy1, xx2, yy2), SquaredDistanceToSegment(x2, y2, xx1, yy1, xx2, yy2)),
        //        Math.Min(SquaredDistanceToSegment(xx1, yy1, x1, y1, x2, y2), SquaredDistanceToSegment(xx2, yy2, x1, y1, x2, y2)));
        //}

        //static int SquaredDistanceToSegment(int x, int y, int x1, int y1, int x2, int y2) {
        //    int result = Math.Min(SquaredDistance(x, y, x1, y1), SquaredDistance(x, y, x2, y2));
        //    if (x1 == x2 && y1 <= y && y <= y2)
        //        result = (x - x1) * (x - x1);
        //    else if (y1 == y2 && x1 <= x && x <= x2)
        //        result = (y - y1) * (y - y1);
        //    return result;
        //}

        static long SquaredDistance(long ax, long ay, long bx, long by) {
            return (ax - bx) * (ax - bx) + (ay - by) * (ay - by);
        }
        #endregion

        #region read helpers
        static int nextInt() {
            int t = input.Read();
            while (t < '0' || t > '9') t = input.Read();
            int x = 0;
            while (t >= '0' && t <= '9') {
                x *= 10;
                x += t - '0';
                t = input.Read();
            }
            return x;
        }

        static long nextLong() {
            int t = input.Read();
            while (t < '0' || t > '9') t = input.Read();
            long x = 0;
            while (t >= '0' && t <= '9') {
                x *= 10;
                x += t - '0';
                t = input.Read();
            }
            return x;
        }

        public static List<int> ReadIntList() {
            return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        }

        public static int[] ReadIntArray() {
            return input.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        }

        public static double[] ReadDoubleArray() {
            return input.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
        }

        public static long[] ReadLongArray() {
            return input.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        }

        public static List<long> ReadLongList() {
            return input.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        }

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

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

        public static long ReadLong() {
            return long.Parse(input.ReadLine());
        }
#endregion
    }

    public class SegmentTree {
        private int[] a, t;
        private int n;
        public SegmentTree(int[] a) {
            n = a.Length;
            this.a = a;
            t = new int[n << 2];
            buildSegmentTree(0, n - 1, 1);
        }

        private void buildSegmentTree(int l, int r, int v) {
            if (l == r)
                t[v] = a[l];
            else {
                int m = (l + r) >> 1;
                int vl = v << 1;
                int vr = (v << 1) | 1;
                buildSegmentTree(l, m, vl);
                buildSegmentTree(m + 1, r, vr);
                t[v] = t[vl] + t[vr];
            }
        }

        public int QuerySegmentTree(int l, int r) {
            return querySegmentTree(1, l, r, 0, n - 1);
        }

        public void Update(int v, int tl, int tr, int pos, int new_val) {
            if (tl == tr)
                t[v] = new_val;
            else {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                    Update(v << 1, tl, tm, pos, new_val);
                else
                    Update(v << 1 + 1, tm + 1, tr, pos, new_val);
                t[v] = t[v << 1] + t[v << 1 + 1];
            }
        }

        private int querySegmentTree(int v, int l, int r, int tl, int tr) {
            if (l > r)
                return 0;
            if (l == tl && r == tr)
                return t[v];
            int m = (tl + tr) >> 1;
            return querySegmentTree(v << 1, l, Math.Min(r, m), tl, m) + querySegmentTree((v << 1) | 1, Math.Max(l, m + 1), r, m + 1, tr);
        }
    }
    class Graph : List<List<int>> {
        public Graph(int num): base(num) {
            for (int i = 0; i < num; i++) {
                this.Add(new List<int>());
            }
        }
    }

    class Heap<T> : IEnumerable<T> where T : IComparable<T> {
        private List<T> heap = new List<T>();
        private int heapSize;
        private int Parent(int index) {
            return (index - 1) >> 1;
        }
        public int Count {
            get { return heap.Count; }
        }
        private int Left(int index) {
            return (index << 1) | 1;
        }
        private int Right(int index) {
            return (index << 1) + 2;
        }
        private void Max_Heapify(int i) {
            int l = Left(i);
            int r = Right(i);
            int largest = i;
            if (l < heapSize && heap[l].CompareTo(heap[i]) > 0)
                largest = l;
            if (r < heapSize && heap[r].CompareTo(heap[largest]) > 0)
                largest = r;
            if (largest != i) {
                T temp = heap[largest];
                heap[largest] = heap[i];
                heap[i] = temp;
                Max_Heapify(largest);
            }
        }
        private void BuildMaxHeap() {
            for (int i = heap.Count >> 1; i >= 0; --i)
                Max_Heapify(i);
        }

        public IEnumerator<T> GetEnumerator() {
            return heap.GetEnumerator();
        }

        public void Sort() {
            for (int i = heap.Count - 1; i > 0; --i) {
                T temp = heap[i];
                heap[i] = heap[0];
                heap[0] = temp;
                --heapSize;
                Max_Heapify(0);
            }
        }

        public T Heap_Extract_Max() {
            T max = heap[0];
            heap[0] = heap[--heapSize];
            Max_Heapify(0);
            return max;
        }

        public void Clear() {
            heap.Clear();
            heapSize = 0;
        }

        public void Insert(T item) {
            if (heapSize < heap.Count)
                heap[heapSize] = item;
            else
                heap.Add(item);
            int i = heapSize;
            while (i > 0 && heap[Parent(i)].CompareTo(heap[i]) < 0) {
                T temp = heap[i];
                heap[i] = heap[Parent(i)];
                heap[Parent(i)] = temp;
                i = Parent(i);
            }
            ++heapSize;
        }

        IEnumerator IEnumerable.GetEnumerator() {
            return ((IEnumerable)heap).GetEnumerator();
        }
    }
    public class Treap<T> where T:IComparable<T> {
        private static Random rand = new Random();
        public static Treap<T> Merge(Treap<T> l, Treap<T> r) {
            if (l == null) return r;
            if (r == null) return l;
            Treap<T> res = null;
            if (l.y > r.y) {
                Treap<T> newR = Merge(l.right, r);
                res = new Treap<T>(l.x, l.y, l.left, newR);
            }
            else {
                Treap<T> newL = Merge(l, r.left);
                res = new Treap<T>(r.x, r.y, newL, r.right);
            }
            return res;
        }

        public bool Contains(T key) {
            if (x.CompareTo(key) > 0)
                return left == null ? false : left.Contains(key);
            else if (x.CompareTo(key) < 0)
                return right == null ? false : right.Contains(key);
            return true;
        }

        public void Split(T x, out Treap<T> l, out Treap<T> r) {
            Treap<T> newTree = null;
            if (this.x.CompareTo(x)<0) {
                if (right == null)
                    r = null;
                else
                    right.Split(x, out newTree, out r);
                l = new Treap<T>(this.x, y, left, newTree);
            }
            else {
                if (left == null)
                    l = null;
                else
                    left.Split(x, out l, out newTree);
                r = new Treap<T>(this.x, y, newTree, right);
            }
        }

        public Treap<T> Add(T x) {
            Treap<T> l, r;
            Split(x, out l, out r);
            Treap<T> m = new Treap<T>(x, rand.Next());
            return Merge(Merge(l, m), r);
        }

        private T x;
        private int y;
        private Treap<T> left, right;
        public Treap(T x, int y, Treap<T> l, Treap<T> r) {
            this.x = x;
            this.y = y;
            left = l;
            right = r;
        }
        public Treap(T x, int y) : this(x, y, null, null) { }
        public Treap(T x) : this(x, rand.Next()) { }
    }
    public static class Extensions {
        public static int Max(this int a, int b) {
            return Math.Max(a, b);
        }

        public static int Min(this int a, int b) {
            return Math.Min(a, b);
        }

        public static void Fill(this int[] array, int val) {
            for (int i = 0; i < array.Length; i++) {
                array[i] = val;
            }
        }

        public static void Fill(this double[] array, double val) {
            for (int i = 0; i < array.Length; i++) {
                array[i] = val;
            }
        }

        public static int ToInt(this string s) {
            return int.Parse(s);
        }

        public static string Fill(this char c, int count) {
            char[] r = new char[count];
            for (int i = 0; i < count; ++i)
                r[i] = c;
            return new string(r);
        }

        public static void Print<T>(this IEnumerable<T> arr) {
            foreach (T t in arr)
                Console.Write("{0} ", t);
        }
    }
}


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

namespace CF {
	class Program {

		static void Main(string[] args) {

#if DEBUG
			TextReader reader = new StreamReader("../../input.txt");

#else
			TextReader reader = Console.In;
#endif

			int[] l1 = reader.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
			int[] l2 = reader.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

			int a = l1[0], b = l1[1], m = l1[2];
			int vx = l2[0], vy = l2[1], vz = l2[2];

			double time = m * 1.0 / -vy;

			//double zdist = vz * time;

			double xpos = a * 1.0 / 2 + vx * time;
			xpos = xpos - 2 * a * Math.Floor(xpos / (2 * a));
			if (xpos > a) {
				xpos = 2 * a - xpos;
			}

			//Console.WriteLine(xpos);

			double zpos = vz * time;
			zpos = zpos - 2 * b * Math.Floor(zpos / (2 * b));
			if (zpos > b) {
				zpos = 2 * b - zpos;
			}

			Console.WriteLine(xpos + " " + zpos);

#if DEBUG
			Console.ReadKey();
#endif

		}

	}
}


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

public class taskD
{
    static void Main(string[] args)
    {
        string inp = Console.ReadLine();
        string[] spl = inp.Split(' ');

        int a, b, m;
        a = int.Parse(spl[0]);
        b = int.Parse(spl[1]);
        m = int.Parse(spl[2]);

        inp = Console.ReadLine();
        spl = inp.Split(' ');

        int vx, vy, vz;
        vx = int.Parse(spl[0]);
        vy = int.Parse(spl[1]);
        vz = int.Parse(spl[2]);

        double t = -(double)m / vy;

        double x0 = (double)a / 2.0 + t * vx;
        double z0 = t * vz;

        bool invx = false;
        bool invz = false;

        while (x0 > a)
        {
            x0 -= a;
            invx = !invx;
        }
        while (x0 < 0)
        {
            x0 += a;
            invx = !invx;
        }
        while (z0 > b)
        {
            z0 -= b;
            invz = !invz;
        }
        while (z0 < 0)
        {
            z0 += b;
            invz = !invz;
        }

        if (invx) x0 = a - x0;
        if (invz) z0 = b - z0;

        Console.WriteLine("{0} {1}", x0, z0);
    }

}


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

public class taskD
{
    static void Main(string[] args)
    {
        string inp = Console.ReadLine();
        string[] spl = inp.Split(' ');

        int a, b, m;
        a = int.Parse(spl[0]);
        b = int.Parse(spl[1]);
        m = int.Parse(spl[2]);

        inp = Console.ReadLine();
        spl = inp.Split(' ');

        int vx, vy, vz;
        vx = int.Parse(spl[0]);
        vy = int.Parse(spl[1]);
        vz = int.Parse(spl[2]);

        double t = -(double)m / vy;

        double x0 = (double)a / 2.0 + t * vx;
        double z0 = t * vz;

        bool invx = false;
        bool invz = false;

        while (x0 > a)
        {
            x0 -= a;
            invx = !invx;
        }
        while (x0 < -a)
        {
            x0 += a;
            invx = !invx;
        }
        while (z0 > b)
        {
            z0 -= b;
            invz = !invz;
        }
        while (z0 < -b)
        {
            z0 += b;
            invz = !invz;
        }

        if (invx) x0 = a - x0;
        if (invz) z0 = b - z0;

        Console.WriteLine("{0} {1}", x0, z0);
    }

}


using System;
class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.In.ReadToEnd().Split(new char[] {'\r', '\n', '\t', ' '}, StringSplitOptions.RemoveEmptyEntries);
            long price = long.Parse(input[1]);
            long res = price/2L;
            long count = 1L;
            for(int i = input.Length-2; i>1; --i)
            {
                res += price * count;
                count *= 2L;
                if(input[i].Length>4)
                {
                    res += price / 2L;
                    count++;
                }
            }
            Console.WriteLine(res);
        }
    }


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

namespace MyFirst
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Choice.Simple();

        }
    }// End OF Program Class

    public class Choice
    {

        public static void Simple()
        {
            // ..................... Program Begin...............................
            // Take String From Input Line .............
            string input1 = Console.ReadLine();
            Scanner Input1 = new Scanner(input1);

            // .....................Take Necessary Input  Formate For Program ...............................

            int n = Input1.TakeIntInputNext();
            int p = Input1.TakeIntInputNext();

            double total=0,ans = 0;
            List<string> s = new List<string>();

            for (int i = 1; i <= n; i++)
            {
                s.Add(Console.ReadLine());
            }

            //.......................... Calculation....................................................
            for (int i = n-1; i >= 0; i--)
            {
                if (s.ElementAt(i) == "halfplus")
                {
                    total += .5;
                    ans += total * p;
                    total *= 2;
                }
                else
                {
                    if (total == 0) total++;
                    ans += total * p;
                    total *= 2;
                }
            }

            //................ OutPut ............................................
           Console.WriteLine("{0}", System.Convert.ToInt64(ans));
            //......................... Program End ..............................

        }

    }

    public class Scanner
    {
        string Input;
        string[] InputArray;
        int Index = 0;
        public int LengthInputString;

        public Scanner(string Input)
        {
            this.Input = Input;
            InputArray = this.Input.Split(' ');
            LengthInputString = InputArray.Length;
        }

        public Scanner(string Input, char split)
        {
            this.Input = Input;
            InputArray = this.Input.Split(split);
            LengthInputString = InputArray.Length;
        }

        public int TakeIntInputNext()
        {
            return (System.Convert.ToInt32(InputArray[Index++]));
        }

        public double TakeDoubleInputNext()
        {
            return (System.Convert.ToDouble(InputArray[Index++]));
        }

        public string TakeStringInputNext()
        {
            return InputArray[Index++].ToString();
        }

        public char TakeOneCharInputNext()
        {
            return System.Convert.ToChar(InputArray[Index++]);
        }

        public char[] TakeCharArrayInputNext()
        {
            return InputArray[Index++].ToCharArray();
        }

        public string Take_Specific_String_Input(int index)
        {
            return InputArray[index].ToString();
        }

    }
}


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

class Program
{
    public static long ScalarProduct(long x1, long y1, long x2, long y2)
    {
        return x1 * y2 - x2 * y1;
    }

    private static int LogR(int radix, long value)
    {
        int ans = 0;
        while (value > 1)
        {
            ans++;
            value /= radix;
        }

        return ans;
    }

    private static bool IsPowerOf2(long x)
    {
        return (x & (x - 1)) == 0;
    }

    private static long BinPower(long x, int power)
    {
        long ans = 1;
        while (power > 0)
        {
            if (power % 2 == 1)
                ans = (ans * x);

            x = x * x;
        }

        return ans;
    }

    private static long Fact(int x)
    {
        long ans = 1;
        for (int i = 2; i <= x; i++)
            ans *= i;
        return ans;
    }

    private static long Placing(int k, int n)
    {
        long ans = Fact(n) / (Fact(k) * Fact(n - k));

        return ans;
    }

    private static void Main(string[] args)
    {
        int n = ReadInt();
        long p = ReadLong();

        string[] s = new string[n];
        for (int i = 0; i < n; i++)
        {
            s[i] = new string(ReadString());
        }

        long ans = 0;
        long extra = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            ans *= 2;
            if (s[i].Length > 5)
            {
                ans++;
                extra++;
            }
        }

        Console.WriteLine(ans * p - extra * (p / 2));
    }

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

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

        return g;
    }

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

        return matrix;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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

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

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

    private static void PushTestData(string data)
    {
        #if !ONLINE_JUDGE
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

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

}


#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

namespace ed9a
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
#if DEBUG
        static bool _useFileInput = false;
#else
        static bool _useFileInput = false;
#endif

        static void Main(string[] args)
        {
            StreamWriter file = null;
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }

#if DEBUG
			if (!_useFileInput)
			{
				Console.SetIn(getInput());
			}
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var d = readIntArray();
            var n = d[0];
            var p = d[1];
            var bs = new int[n];
            for (int i = 0; i < n; i++)
            {
                var next = Console.ReadLine();
                if (next == "half")
                {
                    bs[i] = 0;
                }
                else
                {
                    bs[i] = 1;
                }
            }

            long res = 0L;
            var cc = 0L;
            for (int i = n - 1; i >= 0; i--)
            {
                if (bs[i] == 0)
                {
                    res += cc * p;
                    cc *= 2;
                }
                else
                {
                    res += cc * p + p / 2;
                    cc *= 2;
                    cc++;
                }
            }

            Console.WriteLine(res);
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

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

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}