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

namespace ForAll
{
    class Program
    {

        static void Main(string[] args)
        {
            Int64[] parametrs = Array.ConvertAll(Console.ReadLine().Split(' '),Int64.Parse);

            var n = parametrs[0];int l = (int)parametrs[1],r = (int)parametrs[2];

            int lengthString = (int)Math.Pow(2, ((int)Math.Log(n, 2)) + 1) - 1;

            int index = l;

            int counter = 0;
            for (int i = l; i < r + 1; i++)
            {
                if (BinarySearch(lengthString, n, i) == 1)
                    counter++;
            }

            Console.WriteLine(counter);
        }

        static int BinarySearch(int lengthValue,Int64 root,int index)
        {
            int current = lengthValue / 2 + 1;
            int path = current;
            while (current != index)
            {
                path = path >> 1;
                if (index < current)
                    current = current - path;
                else
                    current = current + path;
                root = root >> 1;
            }

            if (index % 2 == 0)
                return (int)(root % 2);
            else return (int)(root);
        }

    }
}


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

namespace Codeforces
{
	internal class Template
	{
		private Dictionary<Tuple<long, long, long>, long> dp;

		private void Solve()
		{
			dp = new Dictionary<Tuple<long, long, long>, long>();

			var n = cin.NextLong();
			var l = cin.NextLong();
			var r = cin.NextLong();

			if (n == 0)
			{
				Console.WriteLine(0);
				return;
			}

			var count = Count(n, l-1, r-1);
			Console.WriteLine(count);
		}

		private long Count(long n, long l, long r)
		{
			if (n == 1)
			{
				return 1;
			}

			if (dp.ContainsKey(Tuple.Create(n, l, r)))
			{
				return dp[Tuple.Create(n, l, r)];
			}

			var idx = 0;
			var nn = n;
			while (nn > 1)
			{
				idx++;
				nn/=2;
			}
			var len = 1L;
			for (var i = 0; i < idx; i++)
			{
				len *= 2;
				len++;
			}
			var middle = len/2;
			var sum = 0L;
			if (l <= middle && r >= middle)
			{
				sum += n%2;
				if (l < middle)
				{
					sum += Count(n/2, l, middle - 1);
				}
				if (r > middle)
				{
					sum += Count(n/2, 0, r - middle - 1);
				}
			}
			else if (l < middle)
			{
				sum += Count(n/2, l, r);
			}
			else
			{
				sum += Count(n/2, l - middle - 1, r - middle - 1);
			}
			dp[Tuple.Create(n, l, r)] = sum;
			return sum;
		}

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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

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


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

namespace Code_For_1
{
    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)
        {
            long n = Next();
            long l = Next();
            long r = Next();

            string s = Convert.ToString(n, 2);

            long step = 1;
            long sum = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '1')
                {
                    long bl = (l - step + 2*step - 1)/(2*step);
                    long br = (r + 1 - step + 2*step - 1)/(2*step);
                    sum += br - bl;
                }

                step *= 2;
            }

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

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


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

namespace Codeforces
{
	internal class Template
	{
		private Dictionary<Tuple<long, int, int>, long> dp;

		private void Solve()
		{
			dp = new Dictionary<Tuple<long, int, int>, long>();

			var n = cin.NextLong();
			var l = cin.NextLong();
			var r = cin.NextLong();

			if (n == 0)
			{
				Console.WriteLine(0);
				return;
			}

			var count = Count(n, l, r);
			Console.WriteLine(count);
		}

		private long Count(long n, int l, int r)
		{
			if (n == 1)
			{
				return 1;
			}

			if (dp.ContainsKey(Tuple.Create(n, l, r)))
			{
				return dp[Tuple.Create(n, l, r)];
			}

			var idx = 0;
			var nn = n;
			while (nn > 1)
			{
				idx++;
				nn/=2;
			}
			var len = 1;
			for (var i = 0; i < idx; i++)
			{
				len *= 2;
				len++;
			}
			var middle = len/2;
			var sum = 0L;
			if (l <= middle && r >= middle)
			{
				sum += n%2;
				if (l < middle)
				{
					sum += Count(n/2, l, middle - 1);
				}
				if (r > middle)
				{
					sum += Count(n/2, 0, r - middle - 1);
				}
			}
			else if (l < middle)
			{
				sum += Count(n/2, l, r);
			}
			else
			{
				sum += Count(n/2, l - middle - 1, r - middle - 1);
			}
			dp[Tuple.Create(n, l, r)] = sum;
			return sum;
		}

		private static readonly Scanner cin = new Scanner();

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

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

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

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

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

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

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


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

class Program
{
    public class Heap<T> where T : IComparable<T>
    {
        private T[] heap;
        private int size;

        public Heap(int capacity)
        {
            heap = new T[capacity + 1];
            this.size = 0;
        }

        public Heap(IEnumerable<T> items)
        {
            var arr = items.ToArray();
            Array.Sort(arr);
            this.heap = new T[items.Count() + 1];
            Array.Copy(arr, 0, this.heap, 1, arr.Length);
        }

        public void Add(T x)
        {

            this.heap[++size] = x;
            UpdateDown(size);
        }

        public T Get()
        {
            return this.heap[1];
        }

        public T Pop()
        {
            var ans = this.heap[1];
            this.Swap(1, this.size);
            this.size--;
            this.UpdateTop(1);
            return ans;
        }

        public int Size()
        {
            return this.size;
        }

        private void UpdateTop(int t)
        {
            while (true)
            {
                int min = t;
                if (t + t <= size && this.heap[t + t].CompareTo(this.heap[min]) < 0) min = t + t;
                if (t + t + 1 <= size && this.heap[t + t + 1].CompareTo(this.heap[min]) < 0) min = t + t + 1;
                if (min == t) return;

                T tmp = this.heap[min];
                this.heap[min] = this.heap[t];
                this.heap[t] = tmp;

                t = min;
            }
        }

        private void UpdateDown(int t)
        {
            while (t > 1 && this.heap[t >> 1].CompareTo(this.heap[t]) > 0)
            {
                Swap(t >> 1, t);
                t /= 2;
            }
        }

        private void Swap(int a, int b)
        {
            T tmp = this.heap[a];
            this.heap[a] = this.heap[b];
            this.heap[b] = tmp;
        }
    }
    public class State : IComparable<State>
    {
        public int Pos;
        public int Time;
        public int Count;

        public int CompareTo(State other)
        {
            return c[this.Pos].CompareTo(c[other.Pos]);
        }
    }

    private static int[] c;
    public static void Main(string[] args)
    {
        PushTestData(@"
2 1 15
5 6
RG

5 3 10
1 2 3 4 5
RGBRR

");
        var n = RI();
        var s = RI() - 1;
        var k = RI();
        c = RIA(n);
        var color = ReadStringLine();

        var heap = new Heap<State>(5000000);

        var dp = new int[n, 2501];
        var handled = new bool[n, 2501];

        for (int i = 0; i < n; i++)
        {
            heap.Add(new State() { Pos = i, Count = c[i], Time = Math.Abs(i - s) });
            dp[i, Math.Abs(i - s)] = c[i];
        }

        while (heap.Size() > 0)
        {
            var ss = heap.Pop();
            if (handled[ss.Pos, ss.Time]) continue;
            handled[ss.Pos, ss.Time] = true;
            ss.Count = dp[ss.Pos, ss.Time];

            for (int i = 0; i < n; i++)
            {
                if (c[i] > c[ss.Pos] && color[i] != color[ss.Pos])
                {
                    var tm = ss.Time + Math.Abs(i - ss.Pos);
                    var cnt = ss.Count + c[i];
                    if (dp[i, tm] == 0)
                    {
                        heap.Add(new State() { Pos = i, Count = cnt, Time = tm });
                    }

                    dp[i, tm] = Math.Max(dp[i, tm], cnt);
                }
            }
        }

        for (int j = 0; j < 2501; j++)
            for (int i = 0; i < n; i++)
                if (dp[i, j] >= k)
                {
                    Console.WriteLine(j);
                    return;
                }

        Console.WriteLine(-1);
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

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

    private static List<int>[] ReadTree(int n)
    {
        return ReadGraph(n, n - 1);
    }

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

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

        return g;
    }

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

        return matrix;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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

        return s.ToArray();
    }

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

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

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

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

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

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

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

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

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

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


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

namespace mailru2018
{
  class MainClass
  {
    class Box
    {
      public int pos;
      public int candy;
      public int color;
    }

    static int n, s, k;
    static Box[] r;

    static int[,] dp;

    static int find(int at, int candy)
    {
      if (candy >= k)
        return 0;

      if (dp[at, candy] != -1)
        return dp[at, candy];

      int result = int.MaxValue;

      for (int i = at + 1; i < n; ++i)
      {
        if (r[i].color != r[at].color && r[i].candy > r[at].candy)
        {
          int v = find(i, candy + r[i].candy);
          if (v != int.MaxValue)
            result = Math.Min(result, v + Math.Abs(r[at].pos - r[i].pos));
        }
      }

      dp[at, candy] = result;
      return result;
    }

    public static void Main(string[] args)
    {
      //var line = Array.ConvertAll("5 3 10".Split(' '), int.Parse);
      var line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
      n = line[0];
      s = line[1] - 1;
      k = line[2];

      r = new Box[n];
      //line = Array.ConvertAll("1 2 3 4 5".Split(' '), int.Parse);
      line = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
      //var color = "RGBRR";
      var color = Console.ReadLine();

      for (int i = 0; i < n; ++i)
      {
        var box = new Box();
        box.pos = i;
        box.candy = line[i];
        box.color = color[i];
        r[i] = box;
      }

      Array.Sort(r, (x, y) => {
        return x.candy - y.candy;
      });

      dp = new int[n, 2018];
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < 2018; ++j)
          dp[i, j] = -1;

      int result = int.MaxValue;
      for (int i = 0; i < n; ++i)
      {
        var v = find(i, r[i].candy);

        if (v != int.MaxValue)
          result = Math.Min(result, v + Math.Abs(s - r[i].pos));
      }

      if (result == int.MaxValue)
        result = -1;

      Console.WriteLine(result);
    }
  }
}


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

namespace CSharpParser
{
    public class Solution : SolutionBase
    {
        protected override void Solve()
        {
            int n;
            Next(out n);
            int s;
            Next(out s);
            --s;
            int k;
            Next(out k);
            var a = NextArray<int>(n);
            string c;
            Next(out c);
            var m = a.Sum() + 1;
            var d = new int[n, m];
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                    d[i, j] = int.MaxValue;
                d[i, a[i]] = Math.Abs(s - i);
            }
            var u = new bool[n];
            while (true)
            {
                var i = -1;
                for (var l = 0; l < n; l++)
                    if (!u[l] && (i == -1 || a[i] > a[l]))
                        i = l;
                if (i == -1) break;
                u[i] = true;
                for (var j = 0; j < m; j++)
                    if (d[i, j] != int.MaxValue)
                        for (var l = 0; l < n; l++)
                            if (a[l] > a[i] && c[l] != c[i])
                                d[l, j + a[l]] = Math.Min(d[l, j + a[l]], d[i, j] + Math.Abs(i - l));
            }
            var ans = int.MaxValue;
            for (var i = 0; i < n; i++)
                for (var j = k; j < m; j++)
                    ans = Math.Min(ans, d[i, j]);
            PrintLine(ans == int.MaxValue ? -1 : ans);
        }
    }

    public static class Algorithm
    {
        private static readonly Random Rnd = new Random();

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

        public static T Max<T>(params T[] a)
        {
            var ans = a[0];
            var comp = Comparer<T>.Default;
            for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) >= 0 ? ans : a[i];
            return ans;
        }

        public static T Min<T>(params T[] a)
        {
            var ans = a[0];
            var comp = Comparer<T>.Default;
            for (var i = 1; i < a.Length; i++) ans = comp.Compare(ans, a[i]) <= 0 ? ans : a[i];
            return ans;
        }

        public static void RandomShuffle<T>(IList<T> a, int index, int length)
        {
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            var last = index + length;
            if (last > a.Count) throw new ArgumentException();
            for (var i = index + 1; i < last; i++)
            {
                var j = Rnd.Next(index, i + 1);
                var t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
        }

        public static void RandomShuffle<T>(IList<T> a)
        {
            RandomShuffle(a, 0, a.Count);
        }

        public static bool NextPermutation<T>(IList<T> a, int index, int length, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            var last = index + length;
            if (last > a.Count) throw new ArgumentException();
            for (var i = last - 1; i > index; i--)
                if (compare(a[i], a[i - 1]) > 0)
                {
                    var j = i + 1;
                    for (; j < last; j++) if (compare(a[j], a[i - 1]) <= 0) break;
                    var t = a[i - 1];
                    a[i - 1] = a[j - 1];
                    a[j - 1] = t;
                    for (; i < last - 1; i++, last--)
                    {
                        t = a[i];
                        a[i] = a[last - 1];
                        a[last - 1] = t;
                    }
                    return true;
                }
            for (var i = index; i < last - 1; i++, last--)
            {
                var t = a[i];
                a[i] = a[last - 1];
                a[last - 1] = t;
            }
            return false;
        }

        public static bool NextPermutation<T>(IList<T> a, Comparison<T> compare = null)
        {
            return NextPermutation(a, 0, a.Count, compare);
        }

        public static bool PrevPermutation<T>(IList<T> a, int index, int length, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            var last = index + length;
            if (last > a.Count) throw new ArgumentException();
            for (var i = last - 1; i > index; i--)
                if (compare(a[i], a[i - 1]) < 0)
                {
                    var j = i + 1;
                    for (; j < last; j++) if (compare(a[j], a[i - 1]) >= 0) break;
                    var t = a[i - 1];
                    a[i - 1] = a[j - 1];
                    a[j - 1] = t;
                    for (; i < last - 1; i++, last--)
                    {
                        t = a[i];
                        a[i] = a[last - 1];
                        a[last - 1] = t;
                    }
                    return true;
                }
            for (var i = index; i < last - 1; i++, last--)
            {
                var t = a[i];
                a[i] = a[last - 1];
                a[last - 1] = t;
            }
            return false;
        }

        public static bool PrevPermutation<T>(IList<T> a, Comparison<T> compare = null)
        {
            return PrevPermutation(a, 0, a.Count, compare);
        }

        public static int LowerBound<T>(IList<T> a, int index, int length, T value, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            if (index + length > a.Count) throw new ArgumentException();
            var ans = index;
            var last = index + length;
            var p2 = 1;
            while (p2 <= length) p2 *= 2;
            for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) < 0) ans += p2;
            return ans;
        }

        public static int LowerBound<T>(IList<T> a, T value, Comparison<T> compare = null)
        {
            return LowerBound(a, 0, a.Count, value, compare);
        }

        public static int UpperBound<T>(IList<T> a, int index, int length, T value, Comparison<T> compare = null)
        {
            compare = compare ?? Comparer<T>.Default.Compare;
            if (index < 0 || length < 0) throw new ArgumentOutOfRangeException();
            if (index + length > a.Count) throw new ArgumentException();
            var ans = index;
            var last = index + length;
            var p2 = 1;
            while (p2 <= length) p2 *= 2;
            for (p2 /= 2; p2 > 0; p2 /= 2) if (ans + p2 <= last && compare(a[ans + p2 - 1], value) <= 0) ans += p2;
            return ans;
        }

        public static int UpperBound<T>(IList<T> a, T value, Comparison<T> compare = null)
        {
            return UpperBound(a, 0, a.Count, value, compare);
        }

        public static void Fill<T>(this IList<T> array, T value) where T : struct
        {
            for (var i = 0; i < array.Count; i++)
                array[i] = value;
        }

        public static void Fill<T>(this IList<T> array, Func<int, T> func)
        {
            for (var i = 0; i < array.Count; i++)
                array[i] = func(i);
        }
    }

    public class InStream : IDisposable
    {
        protected readonly TextReader InputStream;
        private string[] _tokens;
        private int _pointer;

        private InStream(TextReader inputStream)
        {
            InputStream = inputStream;
        }

        public static InStream FromString(string str)
        {
            return new InStream(new StringReader(str));
        }

        public static InStream FromFile(string str)
        {
            return new InStream(new StreamReader(str));
        }

        public static InStream FromConsole()
        {
            return new InStream(Console.In);
        }

        public string NextLine()
        {
            try
            {
                return InputStream.ReadLine();
            }
            catch (Exception)
            {
                return null;
            }
        }

        private string NextString()
        {
            try
            {
                while (_tokens == null || _pointer >= _tokens.Length)
                {
                    _tokens = NextLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    _pointer = 0;
                }
                return _tokens[_pointer++];
            }
            catch (Exception)
            {
                return null;
            }
        }

        public bool Next<T>(out T ans)
        {
            var str = NextString();
            if (str == null)
            {
                ans = default(T);
                return false;
            }
            ans = (T)Convert.ChangeType(str, typeof(T));
            return true;
        }

        public T[] NextArray<T>(int length)
        {
            var array = new T[length];
            for (var i = 0; i < length; i++)
                if (!Next(out array[i]))
                    return null;
            return array;
        }

        public T[,] NextArray<T>(int length, int width)
        {
            var array = new T[length, width];
            for (var i = 0; i < length; i++)
                for (var j = 0; j < width; j++)
                    if (!Next(out array[i, j]))
                        return null;
            return array;
        }

        public void Dispose()
        {
            InputStream.Close();
        }
    }

    public class OutStream : IDisposable
    {
        protected readonly TextWriter OutputStream;

        private OutStream(TextWriter outputStream)
        {
            OutputStream = outputStream;
        }

        public static OutStream FromString(System.Text.StringBuilder strB)
        {
            return new OutStream(new StringWriter(strB));
        }

        public static OutStream FromFile(string str)
        {
            return new OutStream(new StreamWriter(str));
        }

        public static OutStream FromConsole()
        {
            return new OutStream(Console.Out);
        }

        public void Print(string format, params object[] args)
        {
            OutputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);
            OutputStream.WriteLine();
        }

        public void PrintLine()
        {
            OutputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            OutputStream.Write(o);
        }

        public void PrintLine<T>(T o)
        {
            OutputStream.WriteLine(o);
        }

        public void PrintArray<T>(IList<T> a, string between = " ", string after = "\n", bool printCount = false)
        {
            if (printCount)
                PrintLine(a.Count);
            for (var i = 0; i < a.Count; i++)
                Print("{0}{1}", a[i], i == a.Count - 1 ? after : between);
        }

        public void Dispose()
        {
            OutputStream.Close();
        }
    }

    public abstract class SolutionBase : IDisposable
    {
        private InStream _in;
        private OutStream _out;

        protected SolutionBase()
        {
            //System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            _in = InStream.FromConsole();
            _out = OutStream.FromConsole();
        }

        protected string NextLine()
        {
            return _in.NextLine();
        }

        protected bool Next<T>(out T ans)
        {
            return _in.Next(out ans);
        }

        protected T[] NextArray<T>(int length)
        {
            return _in.NextArray<T>(length);
        }

        protected T[,] NextArray<T>(int length, int width)
        {
            return _in.NextArray<T>(length, width);
        }

        protected void PrintArray<T>(IList<T> a, string between = " ", string after = "\n", bool printCount = false)
        {
            _out.PrintArray(a, between, after, printCount);
        }

        public void Print(string format, params object[] args)
        {
            _out.Print(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            _out.PrintLine(format, args);
        }

        public void PrintLine()
        {
            _out.PrintLine();
        }

        public void Print<T>(T o)
        {
            _out.Print(o);
        }

        public void PrintLine<T>(T o)
        {
            _out.PrintLine(o);
        }

        public void Dispose()
        {
            _in.Dispose();
            _out.Dispose();
        }

        public void Freopen(string path, FileAccess access)
        {
            switch (access)
            {
                case FileAccess.Read:
                    _in.Dispose();
                    _in = InStream.FromFile(path);
                    break;
                case FileAccess.Write:
                    _out.Dispose();
                    _out = OutStream.FromFile(path);
                    break;
            }
        }

        protected abstract void Solve();

        public static void Main()
        {
            using (var p = new Solution()) p.Solve();
        }
    }
}


using System;

namespace _1057С
{
    class Program
    {
        static readonly int INF = 1000000000;
        static int n, s, k;
        static int[] r;
        static int[][] dps;

        static bool[] dpsc;
        static string clr;
        static void Main(string[] args)
        {
            (n, s, k) = r3i();
            r = ris();
            s--;
            clr = Console.ReadLine();
            dpsc = new bool[n];
            dps = new int[n][];
            int result = INF;
            for (int i = 0; i < n; i++)
            {
                dp(i);
                result = Math.Min(result, dps[i][k] + Math.Abs(s-i));
            }
            Console.WriteLine(result == INF ? -1 : result);
        }

        static void dp(int cur)
        {
            if (dps[cur] != null)
                return;
            dps[cur] = new int[k+1];
            for (int i = r[cur]+1; i < k + 1; i++)
            {
                dps[cur][i] = INF;
            }
            for (int to = 0; to < n; to++)
            {
                if (r[to] > r[cur] && clr[to] != clr[cur])
                {
                    dp(to);
                    for (int i = r[cur] + 1; i < k + 1; i++)
                    {
                        dps[cur][i] = Math.Min(dps[cur][i], dps[to][i-r[cur]] + Math.Abs(cur-to));
                    }
                }
            }
        }

        static int[] ris()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), i => Int32.Parse(i));
        }

        static int ri()
        {
            var i = Console.ReadLine();
            return Int32.Parse(i);
        }
        static (int, int) r2i()
        {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]));
        }
        static (int, int, int) r3i()
        {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]), Int32.Parse(i[2]));
        }
    }
}


using System;

namespace _1057С
{
    class Program
    {
        static readonly int INF = 1000000000;
        static int n, s, k;
        static int[] r;
        static int[][] dps;

        static bool[] dpsc;
        static string clr;
        static void Main(string[] args)
        {
            (n, s, k) = r3i();
            r = ris();
            s--;
            clr = Console.ReadLine();
            dpsc = new bool[n];
            dps = new int[n][];
            int result = INF;
            for (int i = 0; i < n; i++)
            {
                dp(i);
                result = Math.Min(result, dps[i][k] + Math.Abs(s-i));
            }
            Console.WriteLine(result == INF ? -1 : result);
        }

        static void dp(int cur)
        {
            if (dps[cur] != null)
                return;
            dps[cur] = new int[k+1];
            for (int i = r[cur] + 1; i < k + 1; i++)
            {
                dps[cur][i] = INF;
            }
            for (int to = 0; to < n; to++)
            {
                if (r[to] < r[cur] && clr[to] != clr[cur])
                {
                    dp(to);
                    for (int i = r[cur] + 1; i < k + 1; i++)
                    {
                        dps[cur][i] = Math.Min(dps[cur][i], dps[to][i-r[cur]] + Math.Abs(cur-to));
                    }
                }
            }
        }

        static int[] ris()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), i => Int32.Parse(i));
        }

        static int ri()
        {
            var i = Console.ReadLine();
            return Int32.Parse(i);
        }
        static (int, int) r2i()
        {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]));
        }
        static (int, int, int) r3i()
        {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]), Int32.Parse(i[2]));
        }
    }
}


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

class Program
{
    public class Heap<T> where T : IComparable<T>
    {
        private T[] heap;
        private int size;

        public Heap(int capacity)
        {
            heap = new T[capacity + 1];
            this.size = 0;
        }

        public Heap(IEnumerable<T> items)
        {
            var arr = items.ToArray();
            Array.Sort(arr);
            this.heap = new T[items.Count() + 1];
            Array.Copy(arr, 0, this.heap, 1, arr.Length);
        }

        public void Add(T x)
        {
            this.heap[++size] = x;
            UpdateDown(size);
        }

        public T Get()
        {
            return this.heap[1];
        }

        public T Pop()
        {
            var ans = this.heap[1];
            this.Swap(1, this.size);
            this.size--;
            this.UpdateTop(1);
            return ans;
        }

        public int Size()
        {
            return this.size;
        }

        private void UpdateTop(int t)
        {
            while (true)
            {
                int min = t;
                if (t + t <= size && this.heap[t + t].CompareTo(this.heap[min]) < 0) min = t + t;
                if (t + t + 1 <= size && this.heap[t + t + 1].CompareTo(this.heap[min]) < 0) min = t + t + 1;
                if (min == t) return;

                T tmp = this.heap[min];
                this.heap[min] = this.heap[t];
                this.heap[t] = tmp;

                t = min;
            }
        }

        private void UpdateDown(int t)
        {
            while (t > 1 && this.heap[t >> 1].CompareTo(this.heap[t]) > 0)
            {
                Swap(t >> 1, t);
                t /= 2;
            }
        }

        private void Swap(int a, int b)
        {
            T tmp = this.heap[a];
            this.heap[a] = this.heap[b];
            this.heap[b] = tmp;
        }
    }
    public class State : IComparable<State>
    {
        public int Pos;
        public int Time;
        public int Count;

        public int CompareTo(State other)
        {
            return c[this.Pos].CompareTo(c[other.Pos]);
        }
    }

    private static int[] c;
    public static void Main(string[] args)
    {
        PushTestData(@"
2 1 15
5 6
RG

5 3 10
1 2 3 4 5
RGBRR
");
        var n = RI();
        var s = RI() - 1;
        var k = RI();
        c = RIA(n);
        var color = ReadStringLine();

        var heap = new Heap<State>(5000000);

        var dp = new int[n, 2501];
        var handled = new bool[n, 2501];

        for (int i = 0; i < n; i++)
            heap.Add(new State() { Pos = i, Count = c[i], Time = Math.Abs(i - s) });

        while (heap.Size() > 0)
        {
            var ss = heap.Pop();
            if (handled[ss.Pos, ss.Time]) continue;
            handled[ss.Pos, ss.Time] = true;

            for (int i = 0; i < n; i++)
            {
                if (c[i] > c[ss.Pos] && color[i] != color[ss.Pos])
                {
                    var tm = ss.Time + Math.Abs(i - ss.Pos);
                    var cnt = ss.Count + c[i];
                    if (dp[i, tm] == 0)
                    {
                        heap.Add(new State() { Pos = i, Count = cnt, Time = tm });
                    }

                    dp[i, tm] = Math.Max(dp[i, tm], cnt);
                }
            }
        }

        for (int j = 0; j < 2501; j++)
            for (int i = 0; i < n; i++)
                if (dp[i, j] >= k)
                {
                    Console.WriteLine(j);
                    return;
                }

        Console.WriteLine(-1);
    }

    private const int Mod = 1000000000 + 7;

    #region Data Read

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

    private static List<int>[] ReadTree(int n)
    {
        return ReadGraph(n, n - 1);
    }

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

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

        return g;
    }

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

        return matrix;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return s.ToArray();
    }

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

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

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

        return s;
    }

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

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

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

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

        return s.ToArray();
    }

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

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

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

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

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

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

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

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

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

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


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

class Solution
{
	static void Main (string[] args)
	{
		int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		int n = nums [0];
		int s = nums [1];
		int target = nums [2];
		int[] v = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		string c = Console.ReadLine ();

		List<Node> nodes = new List<Node> ();
		for (int i = 0; i < n; i++) {
			nodes.Add (new Node (i, v [i], c [i]));
		}
		nodes.ForEach (node => node.AddNeighbors (nodes));

		Node initialNode = new Node (s - 1, 0, ' ');
		initialNode.Neighbors = nodes;

		List<State>[] search = new List<State>[n * n + 2];
		for (int i = 0; i < search.Length; i++) {
			search [i] = new List<State> ();
		}
		search [0].Add (new State{ Missing = target, Current = initialNode });

		for (int t = 0; t < search.Length; t++) {
			foreach (State state in search[t]) {
				if (state.Solved) {
					Console.WriteLine (t - 1);
					return;
				}
				foreach (State s2 in state.Expand()) {
					search [s2.Time].Add (s2);
				}
			}
		}
		Console.WriteLine (-1);
	}

	class State {
		public int Missing;
		public Node Current;
		public int Time;

		public bool Solved => Missing <= 0;

		public IEnumerable<State> Expand() {
			foreach(Node n in Current.Neighbors) {
				State s = new State();
				s.Current = n;
				s.Missing = Missing - n.Value;
				s.Time = Time + Current.Dist(n);
				yield return s;
			}
		}
	}

	class Node {
		public int Index;
		public int Value;
		public char Color;
		public List<Node> Neighbors;

		public Node(int index, int value, char color) {
			this.Index = index;
			this.Value = value;
			this.Color = color;
		}

		public int Dist(Node n) {
			return Math.Abs(Index - n.Index) + (Color == ' ' ? 1 : 0);
		}

		public void AddNeighbors(List<Node> nodes) {
			Neighbors = nodes.Where (n => n.Color != this.Color && n.Value > this.Value).ToList ();
		}
	}
}


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

public class taskB
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

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

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] ab = instream.ReadIntArray();

        int a = ab[0];
        int b = ab[1];

        int r1 = a * ((b-1) / 3+1);
        int r2 = ((a-1) / 3 + 1) * b;

        int res = Math.Max(r1, r2);
        outstream.WriteLine(res);
    }

}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n % 2 == 0)
            {
                var low = (int)Math.Round((double)n / 2);
                var up = low;
                sum = (low + up) * (m / 2);
            }
            else
            {
                var low = (int)Math.Round((double)(m / 2) );
                var up = (int)Math.Round((double)(m / 2)+.51);
                sum = (low + up) * (n / 2);
                if (m % 2 != 0) sum += up;
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Help_General
{
    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 m = Next();

            int max = Math.Max(n*((m + 3)/4), m*((n + 3)/4));

            max = Math.Max(max, C2(n)*C2(m));

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

        static int C2(int n)
        {
            if (n % 4 == 1)
            {
                return 2*((n + 2)/4) + 1;
            }
            return 2*((n + 2)/4);
        }

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


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n == 1 || m == 1)
            {
                var t = 1;
                t ^= n ^ m;
                sum = t;
            }
            else
                if (n % 2 == 0)
                {
                    var low = (int)m / 2;
                    var up = low + m % 2;
                    sum = (low + up) * (n / 2);
                }
                else if (m % 2 == 0)
                {
                    var low = (int)n / 2;
                    var up = low + n % 2;
                    sum = (low + up) * (m / 2);
                }
                else
                {
                    var low = (int)n / 2;
                    var up = low + n % 2;
                    sum = (low + up) * (m / 2);
                    sum += up;
                }
            Console.WriteLine(sum);
        }
    }
}


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

public class taskB
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

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

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] ab = instream.ReadIntArray();

        int a = ab[0];
        int b = ab[1];

        if (a > b)
        {
            int t = a;
            a = b;
            b = t;
        }

        int r1 = a * ((b-1) / 3+1);
        int r2 = ((a-1) / 3 + 1) * b;

        int r3 = a * b / 2 + ((a * b) % 2 == 0 ? 0 : 1);

        int res = Math.Max(Math.Max(r1, r2), r3);

        if (a == 2)
        {
            if (b % 4 == 1)
            {
                res = b / 4 * 4 + 2;
            }
            else if (b % 4 == 2)
            {
                res = b / 4 * 4 + 4;
            }
        }
        outstream.WriteLine(res);
    }

}


using System;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

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

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

}

class Myon
{
    Scanner cin;
    Random r;
    Myon() { }

    public static void Main()
    {
        new Myon().calc();
    }

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

    static int[, ,] dp;
    static int[, ,] preput;

    void calc()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int m = cin.nextInt();
        int ret = Math.Max((n + 2) / 3 * m, (m + 2) / 3 * n);
        ret = Math.Max(ret, (n / 4 * 2 + Math.Min(2, n % 4)) * (m / 4 * 2 + Math.Min(2, m % 4)));
        Console.WriteLine(ret);
    }
}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n == 1 || m == 1)
            {
                var t = 1;
                t ^= n ^ m;
                sum = t;
            }
            if (((n == 2) && (m % 2 != 0)) || ((m == 2) && (n % 2 != 0)))
            {
                var t = 2;
                t ^= n ^ m;
                sum = t+1;
            }
            else
                if (n % 2 == 0)
                {
                    var low = (int)m / 2;
                    var up = low + m % 2;
                    sum = (low + up) * (n / 2);
                }
                else if (m % 2 == 0)
                {
                    var low = (int)n / 2;
                    var up = low + n % 2;
                    sum = (low + up) * (m / 2);
                }
                else
                {
                    var low = (int)n / 2;
                    var up = low + n % 2;
                    sum = (low + up) * (m / 2);
                    sum += up;
                }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s=>double.Parse(s));
            var n = input.First();
            var m = input.Last();
            if (n / 3 > m / 3)
            {
                var t = (n / 3) % 1 > 0.5 ? Math.Round(n / 3) : Math.Round(n / 3 + .5);
                Console.WriteLine(t * m);
            }
            else
            {
                var t = (m / 3) % 1 > 0.5 ? Math.Round(m / 3) : Math.Round(m / 3 + .5);
                Console.WriteLine(t * n);
            }
        }
    }
}


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

namespace Help_General
{
    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 m = Next();

            int max = m*n/2;
            if (n%2 == 1 && m%2 == 1)
            {
                max++;
            }

            max = Math.Max(max, n*((m + 2)/3));
            max = Math.Max(max, n*((m + 2)/3));

            max = Math.Max(max, C2(n)*C2(m));

            if (n == 3 && m > 4 && (m%3 == 0 || m%3 == 2))
                max = Math.Max(max, 2 + n*((m + 2)/3));

            if (m == 3 && n > 4 && (n%3 == 0 || n%3 == 2))
                max = Math.Max(max, 2 + m*((n + 2)/3));

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

        private static int C2(int n)
        {
            if (n%4 == 1)
            {
                return 2*((n + 2)/4) + 1;
            }
            return 2*((n + 2)/4);
        }

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


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n % 2 == 0)
            {
                var low = (int)m / 2;
                var up = low + m % 2;
                sum = (low + up) * (n / 2);
            }
            else if (m % 2 == 0)
            {
                var low = (int)n / 2;
                var up = low + n % 2;
                sum = (low + up) * (m / 2);
            }
            else
            {
                var low = (int)n / 2;
                var up = low + n%2;
                sum = (low + up) * (m / 2);
                sum += up;
            }
            Console.WriteLine(sum);
        }
    }
}


using System;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

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

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

}

class Myon
{
    Scanner cin;
    Random r;
    Myon() { }

    public static void Main()
    {
        new Myon().calc();
    }

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

    static int[, ,] dp;
    static int[, ,] preput;

    void calc()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int m = cin.nextInt();
        int ret = Math.Max((n + 2) / 3 * m, (m + 2) / 3 * n);
        Console.WriteLine(ret);
    }
}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s=>int.Parse(s));
            var n = input.First();
            var m = input.Last();
            if ((double)n / 3 > (double)m / 3)
            {
                var t = (n / 3) % 1 > 0.5 ? Math.Round((double)n / 3) : Math.Round(n / 3 + .5);
                Console.WriteLine(t * m);
            }
            else
            {
                var t = (m / 3) % 1 > 0.5 ? Math.Round((double)m / 3) : Math.Round(m / 3 + .5);
                Console.WriteLine(t * n);
            }
        }
    }
}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n == 1 || m == 1)
            {
                var t = 1;
                t ^= n ^ m;
                sum = t;
            }
            else
                if (n == 2|| m == 2)
                {
                    var t = 2;
                    var tt = (m + n) ^ t;
                    t ^= n ^ m;
                    sum = tt%2==0?t+2:t+1;
                }
                else
                    if (n % 2 == 0)
                    {
                        var low = (int)m / 2;
                        var up = low + m % 2;
                        sum = (low + up) * (n / 2);
                    }
                    else if (m % 2 == 0)
                    {
                        var low = (int)n / 2;
                        var up = low + n % 2;
                        sum = (low + up) * (m / 2);
                    }
                    else
                    {
                        var low = (int)n / 2;
                        var up = low + n % 2;
                        sum = (low + up) * (m / 2);
                        sum += up;
                    }
            Console.WriteLine(sum);
        }
    }
}


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

public class taskB
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

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

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] ab = instream.ReadIntArray();

        int a = ab[0];
        int b = ab[1];

        int r1 = a * ((b-1) / 3+1);
        int r2 = ((a-1) / 3 + 1) * b;

        int r3 = a * b / 2 + ((a * b) % 2 == 0 ? 0 : 1);

        int res = Math.Max(Math.Max(r1, r2), r3);
        outstream.WriteLine(res);
    }

}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n == 1 || m == 1)
            {
                var t = 1;
                t ^= n ^ m;
                sum = t;
            }
            else
                if (((n == 2) && (m % 2 != 0)) || ((m == 2) && (n % 2 != 0)))
                {
                    var t = 2;
                    t ^= n ^ m;
                    sum = t + 1;
                }
                else
                    if (n % 2 == 0)
                    {
                        var low = (int)m / 2;
                        var up = low + m % 2;
                        sum = (low + up) * (n / 2);
                    }
                    else if (m % 2 == 0)
                    {
                        var low = (int)n / 2;
                        var up = low + n % 2;
                        sum = (low + up) * (m / 2);
                    }
                    else
                    {
                        var low = (int)n / 2;
                        var up = low + n % 2;
                        sum = (low + up) * (m / 2);
                        sum += up;
                    }
            Console.WriteLine(sum);
        }
    }
}


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

namespace Help_General
{
    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 m = Next();

            int max = m*n/2;
            if (n%2 == 1 && m%2 == 1)
            {
                max++;
            }

            max = Math.Max(max, n*((m + 2)/3));
            max = Math.Max(max, m*((n + 2)/3));

            max = Math.Max(max, C2(n)*C2(m));

            if (n == 3 && m > 4 && (m%3 == 0 || m%3 == 2))
                max = Math.Max(max, 2 + n*((m + 2)/3));

            if (m == 3 && n > 4 && (n%3 == 0 || n%3 == 2))
                max = Math.Max(max, 2 + m*((n + 2)/3));

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

        private static int C2(int n)
        {
            if (n%4 == 1)
            {
                return 2*((n + 2)/4) + 1;
            }
            return 2*((n + 2)/4);
        }

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


using System;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

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

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

}

class Myon
{
    Scanner cin;
    Random r;
    Myon() { }

    public static void Main()
    {
        new Myon().calc();
    }

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

    int[,] dp;

    void calc()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int m = cin.nextInt();
        dp = new int[n + 1, m + 1];
        Console.WriteLine(saiki(n, m));
    }

    int saiki(int a, int b)
    {
        if (a == 0 && b == 0) return a;
        if (dp[a, b] != 0) return dp[a, b];
        int reta = (a / 4) * 2 + Math.Min(a % 4, 2);
        int retb = (b / 4) * 2 + Math.Min(b % 4, 2);
        int ret = reta * retb;
        ret = Math.Max((a + 2) / 3 * b, ret);
        ret = Math.Max((b + 2) / 3 * a, ret);
        if (a > 3) ret = Math.Max(ret, saiki(a - 3, b) + b);
        if (b > 3) ret = Math.Max(ret, saiki(a, b - 3) + a);
        ret = Math.Max(ret, (a * b + 1) / 2);
        return dp[a, b] = ret;
    }
}


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

public class taskB
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

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

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] ab = instream.ReadIntArray();

        int a = ab[0];
        int b = ab[1];

        if (a > b)
        {
            int t = a;
            a = b;
            b = t;
        }

        int r1 = a * ((b-1) / 3+1);
        int r2 = ((a-1) / 3 + 1) * b;

        int r3 = a * b / 2 + ((a * b) % 2 == 0 ? 0 : 1);

        int res = Math.Max(Math.Max(r1, r2), r3);

        if (a == 2)
        {
            if (b % 4 == 1)
            {
                res = b / 4 * 4 + 2;
            }
            else if (b % 4 == 2 || b % 4 == 3)
            {
                res = b / 4 * 4 + 4;
            }
        }
        outstream.WriteLine(res);
    }

}


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

namespace Contest
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            var n = input.First();
            var m = input.Last();
            int sum = 0;
            if (n == 1 || m == 1)
            {
                var t = 1;
                t ^= n ^ m;
                sum = t;
            }
            else
                if (n == 2 || m == 2)
                {
                    var t = 2;
                    t ^= n ^ m;
                    sum = (t / 4)*4;
                    var l = t % 4;
                    if(l>0)
                    sum += (l > 1 ? 2 : 1)*2;
                }
                else sum = (n * m) / 2 + (n * m) % 2;
            Console.WriteLine(sum);
        }
    }
}


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

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {
            int[] arr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int n = arr[0];
            int m = arr[1];
            if (n == 1 || m == 1)
            {
                Console.WriteLine(n*m);
                return;
            }
            if (n == 2 || m == 2)
            {
                int k;
                if (n == 2)
                    k = m;
                else
                    k = n;
                int z = 0;
                for (int i = 0; i < k; i++)
                {
                    if (i % 4 == 0)
                        z += 1;
                    if (i % 4 == 1)
                        z++;
                }
                Console.WriteLine(z*2);
                return;
            }
            int kk = 0;
            for (int i = 0; i < n; i++)
            {
                    if (i % 2 == 0)
                    {
                        kk += (m + 1) / 2;
                    }
                    else
                    {
                        kk += m / 2;
                    }

            }
            Console.WriteLine(kk);
        }
    }
}


using System;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

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

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

}

class Myon
{
    Scanner cin;
    Random r;
    Myon() { }

    public static void Main()
    {
        new Myon().calc();
    }

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

    int[,] dp;

    void calc()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int m = cin.nextInt();
        dp = new int[n + 1, m + 1];
        Console.WriteLine(saiki(n, m));
    }

    int saiki(int a, int b)
    {
        if (a == 0 && b == 0) return a;
        if (dp[a, b] != 0) return dp[a, b];
        int reta = (a / 4) + Math.Min(a % 4, 2);
        int retb = (b / 4) + Math.Min(b % 4, 2);
        int ret = reta * retb;
        ret = Math.Max((a + 2) / 3 * b, ret);
        ret = Math.Max((b + 2) / 3 * a, ret);
        if (a > 3) ret = Math.Max(ret, saiki(a - 3, b) + b);
        if (b > 3) ret = Math.Max(ret, saiki(b - 3, a) + a);
        ret = Math.Max(ret, (a * b + 1) / 2);
        return dp[a, b] = ret;
    }
}


using System;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            int days = int.Parse(Console.ReadLine());
            var _temp = Console.ReadLine().Split(' ');

            bool _flag = true;
            int zeroDay, secondDay, progress, expectedTemp, currTemp = 0;

            zeroDay = int.Parse(_temp[0]);
            secondDay = int.Parse(_temp[1]);

            progress = secondDay - zeroDay;
            if (days >= 3)
            {
                for (int i = 1; i < days; i++)
                {
                    currTemp = int.Parse(_temp[i]);
                    expectedTemp = int.Parse(_temp[i - 1]) + progress;
                    if(currTemp != expectedTemp)
                    {
                        _flag = false;
                        break;
                    }
                }
                if(_flag)
                {
                    Console.WriteLine(currTemp + progress);

                }
                else
                {
                    Console.WriteLine(_temp[days - 1]);
                }

            }
            else
            {
                expectedTemp = zeroDay + progress * (days - 1);

                if (int.Parse(_temp[days - 1]) == expectedTemp)
                {
                    Console.WriteLine(expectedTemp + progress);

                }
                else
                    Console.WriteLine(_temp[days - 1]);
            }

        }
    }
}


using System;
// you can also use other imports, for example:
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class HelloWorld {

	public static void Main(string[] args)
	{
		int n = Convert.ToInt32(Console.ReadLine());
		int[] ar = Array.ConvertAll(Console.ReadLine().Split(' '), t => Convert.ToInt32(t));

		var ratio = ar[1] - ar[0];
		for (var i = 2; i < n; i++)
		{
			if (ratio != ar[i] - ar[i-1])
			{
				ratio = 0;
				break;
			}
		}

		if (ratio == 0)
			Console.WriteLine(ar[n-1]);
		else
			Console.WriteLine(ar[n-1]+ratio);

	}

}


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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k,a=0;
            n = Convert.ToInt32(Console.ReadLine());
            n--;
            string[] t = Console.ReadLine().Split();

            k = Convert.ToInt32(t[n]) - Convert.ToInt32(t[n - 1]);

            for (int i = 0; i <= n-1; i++)
                if (Convert.ToInt32(t[i + 1]) - Convert.ToInt32(t[i]) == k) a++;

            if (a == n) Console.WriteLine(Convert.ToInt32(t[n]) + k);
            else    Console.WriteLine(Convert.ToInt32(t[n]));
        }
    }
}


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

namespace ConsoleApplication1A
{
  class ProgramBBB
  {
    static void Main(string[] args)
    {

      int n = Convert.ToInt32(Console.ReadLine());
      string[] tk = Console.ReadLine().Split(' ');
      int[] M = new int[n];
      for (var i = 0; i < n; i++)
      {
        M[i] = Convert.ToInt32(tk[i]);
      }

      int d = M[1] - M[0];

      bool progr = true;
      for (var i = 1; i < n; i++)
      {
        progr = (M[i] - M[i - 1] == d);
        if (progr == false) break;
      }

      if (!progr) Console.WriteLine(M[n - 1]); else Console.WriteLine(M[n - 1] + d);
    }

  }
}


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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            int b;

            int n = Convert.ToInt32(Console.ReadLine());

            int[] temp = new int[n];

            string[] tempStr = new string[n];

            string str = Console.ReadLine();

            char[] split = { ' ' };

            tempStr = str.Split(split);

            for (int k = 0; k <= n - 1; k++)
            {
                temp[k] = Convert.ToInt32(tempStr[k]);
            }

            int m = temp[0] - temp[1];
            b = 0;

            for (int k = 0; k <= n - 2; k++)
            {
                if (temp[k] - temp[k + 1] == m)
                {
                    b = b + 1;
                }
            }

            if (n > 2)
            {
                if (b == n - 1 && temp[n - 1] - temp[n - 2] == temp[n - 2] - temp[n - 3])
                {
                    Console.WriteLine(temp[n - 1] + temp[n - 1] - temp[n - 2]);
                }
                else
                {
                    Console.WriteLine(temp[n - 1]);
                }
            }
            else
            {
                Console.WriteLine(temp[n - 1] + temp[n - 1] - temp[n - 2]);
            }
        }
    }
}


//
/* Date: 18.09.2017 * Time: 22:45 */
// *

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

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

class Example
{
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2017\\Task\\07 Codeforces\\026\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2017\\Task\\07 Codeforces\\026\\A.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		int n;
		string ss;
# if ( ONLINE_JUDGE )
		n = int.Parse (Console.ReadLine ());
		ss = Console.ReadLine ();
# else
		n = int.Parse (sr.ReadLine ());
		ss = sr.ReadLine ();
		sw.WriteLine (ss);
# endif

		int [] t = new int [n];
		string [] s = ss.Split (' ');

		for ( int i=0; i < n; i++ )
			t [i] = int.Parse (s [i]);

		int d = t [1] - t [0];
		bool ok = true;
		for ( int j=2; j < n; j++ )
			if ( t [j] != t [j-1] + d )
			{
				ok = false;
				break;
			}

		if ( ! ok )
			d = 0;

# if ( ONLINE_JUDGE )
		Console.WriteLine (t [n-1] + d);
# else
		sw.WriteLine (t [n-1] + d);
		sw.Close ();
# endif

	}
}


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

namespace qwerty
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 n = Int32.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(Int32.Parse).ToArray();
            int k = a[1] - a[0];
            bool isAr = true;
            for(int i=2;i<n;i++)
            {
                if(a[i]-a[i-1]!=k)
                {
                    isAr = false;
                    break;
                }
            }

            if(isAr)
            {
                Console.WriteLine(k + a[a.Length - 1]);
            }
            else
            {
                Console.WriteLine(a[a.Length - 1]);
            }

        }
    }
}


using System;

class Program
{
	static void Main()
	{
		int n = Convert.ToInt32(Console.ReadLine());
		string inp = Console.ReadLine();
		string[] par = inp.Split(' ');
		int i, d, prognoz;

		int[] a = new int[n];

		for (i = 0; i < n; i++)
			a[i] = Convert.ToInt32(par[i]);

		d = (a[1] - a[0]);

		for (i = 1; i < n; i++)
		{
			if (a[i] - a[i - 1] != d)
			{
				d = 0;
			}
		}

		prognoz = a[n - 1] + d;

		Console.WriteLine("{0}", prognoz);
	}
}


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

namespace Training_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int dif = 0;
            int check = 0;
            int last_day = 0; ;
            int[] t = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            for (int i =0;i<t.Length;i++)
            {
                if (i == 0)
                {
                    dif = t[i + 1] - t[i];
                }
                if (i != t.Length - 1)
                {
                    if (t[i + 1] - t[i] != dif)
                    {
                        check++;
                    }
                }
                if (i == t.Length - 1)
                {
                     last_day = t[t.Length - 1];
                }
            }
            if (check ==0)
            {
                Console.Write($"{last_day + dif}");
            }
            else
            {
                Console.Write($"{last_day}");
            }

        }
    }
}


// Problem: 847M - Weather Tomorrow
// Author: Gusztav Szmolik

using System;

class WeatherTomorrow
    {
    static int Main ()
        {
        string[] words = ReadSplitLine (1);
        if (words == null)
            return -1;
        byte n;
        if (!Byte.TryParse (words[0], out n))
            return -1;
        if (n < 2 || n > 100)
            return -1;
        words = ReadSplitLine (n);
        if (words == null)
            return -1;
        short tPrev = 0;
        short d = 0;
        bool ap = true;
        for (byte i = 0; i < n; i++)
            {
            short ti;
            if (!Int16.TryParse (words[i], out ti))
                return -1;
            if (ti < -1000 || ti > 1000)
                return -1;
            if (i == 1)
                d = Convert.ToInt16 (ti-tPrev);
            else if (i > 1 && ap && ti-tPrev != d)
                ap = false;
            tPrev = ti;
            }
        short ans = Convert.ToInt16 (ap ? tPrev+d : tPrev);
        Console.WriteLine (ans);
        return 0;
        }

    static string[] ReadSplitLine (uint numWordNeed)
        {
        string line = Console.ReadLine ();
        if (line == null)
            return null;
        char[] delims = new char[2] {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        return (words.Length == numWordNeed ? words : null);
        }
    }


using System;

class Program
{
	static void Main()
	{
		int n = Convert.ToInt32(Console.ReadLine());
		string inp = Console.ReadLine();
		string[] par = inp.Split(' ');
		int i, d, prognoz;

		int[] a = new int[n];

		for (i = 0; i < n; i++)
			a[i] = Convert.ToInt32(par[i]);

		d = (a[n - 1] - a[0]) / (n - 1);

		for (i = 1; i < n; i++)
		{
			if (a[i] - a[i - 1] != d)
			{
				d = 0;
			}
		}

		/*if (d == a[1] - a[0])
			prognoz = a[n - 1] + d;
		else
			prognoz = a[n - 1];*/

		prognoz = a[n - 1] + d;

		Console.WriteLine("{0}", prognoz);
	}
}


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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int k = a[n - 1] - a[n - 2];
            bool x = true;
            for (int i = 1; i < n; i++)
            {
                if (a[i] - a[i - 1] != k)
                {
                    x = false;
                }
            }
            int max = a[n - 1];
            if (x)
                max = a[n - 1] + (a[n - 1] - a[n - 2]);

            Console.WriteLine(max);
            //Console.ReadKey();
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            string[] y = Console.ReadLine().Split(' ');
            int a = int.Parse(y[0]) - int.Parse(y[1]);
            if (y.Length == 2)
            {
                if (int.Parse(y[0]) + a == int.Parse(y[1]))
                    Console.WriteLine(int.Parse(y[y.Length - 1]) + a);
                else if (int.Parse(y[0]) - a == int.Parse(y[1]))
                    Console.WriteLine(int.Parse(y[y.Length - 1]) - a);
                else
                    Console.WriteLine(y[y.Length - 1]);
            }
            else
            {
                for (int i = 0; i < y.Length - 1; i++)
                {
                    if ((int.Parse(y[i]) + a) == (int.Parse(y[i + 1]) + a * 2))
                    {

                    }
                    else
                    {
                        Console.WriteLine(int.Parse(y[y.Length - 1]));
                        break;
                    }
                    if (i == y.Length - 2)
                    {
                        Console.WriteLine(int.Parse(y[y.Length - 1]) - a);
                        break;
                    }
                }
            }
            //            int a = int.Parse(y[0]);
            //            int b = int.Parse(y[1]);
            //            //int max = -99999999;
            //            int k = 0;
            //            string c = Console.ReadLine();
            //            char[]v=new char[c.Length];
            //                        for (int i = 0; i < a; i++)
            //            {
            //v[i]=c[i];
            //            }
            //            //int i = 0;
            //            int h2 = 0;
            //            int h5 = 0;
            //            for (int i = 0; i < b; i++)
            //            {
            //                for (int j = 0; j < v.Length-1; j++)
            //                {
            //                    if ((v[i] == 'B') && (v[i + 1] == 'G') && (v[i - 1] == 'G'))
            //                    {
            //                        v[i] = 'G';
            //                        v[i + 1] = 'B';
            //                        //Console.WriteLine();

            //                        j+=2;
            //                    }
            //                }
            //            }
            //            for (int h = 0; h < v.Length; h++)
            //            {
            //                Console.Write(v[h]);
            //            }
            //Console.ReadKey();
        }
    }
}


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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int d = 0;
            bool test;
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            if (n == 1)
                Console.WriteLine(s[0]);
            else if (n == 2)
            {
                Console.WriteLine(int.Parse(s[1]) - int.Parse(s[0]) + int.Parse(s[1]));
            }
            else
            {
                test = true;
                d = int.Parse(s[1]) - int.Parse(s[0]);
                for (int i = 2; i < n; i++)
                {
                    if (int.Parse(s[i]) - int.Parse(s[i-1]) != d)
                    {
                        test = false;
                        break;
                    }
                }
                if (test)
                    Console.WriteLine(int.Parse(s[s.Length - 1]) + d);
                else
                    Console.WriteLine(s[s.Length - 1]);
            }
        }
    }
}