using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int H = int.Parse(str[0]);
        int W = int.Parse(str[1]);
        int[,] D = new int[H,W];
        for(int i=0;i<H;i++){
            str = Console.ReadLine().Split(' ');
            for(int j=0;j<W;j++){
                D[i,j] = int.Parse(str[j]);
            }
        }
        int S = H*W;
        int G = H*W+1;
        List<int> F = new List<int>();
        List<int> T = new List<int>();
        List<long> capacity = new List<long>();
        List<long> cost = new List<long>();
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if((i+j) % 2 == 0){
                    F.Add(S);
                    T.Add(i*W+j);
                    capacity.Add(1);
                    cost.Add(0);
                    if(i != 0){
                        F.Add(i*W+j);
                        T.Add((i-1)*W+j);
                        capacity.Add(1);
                        cost.Add(D[i-1,j] == D[i,j] ? 0 : 1);
                    }
                    if(i != H-1){
                        F.Add(i*W+j);
                        T.Add((i+1)*W+j);
                        capacity.Add(1);
                        cost.Add(D[i+1,j] == D[i,j] ? 0 : 1);
                    }
                    if(j != 0){
                        F.Add(i*W+j);
                        T.Add(i*W+(j-1));
                        capacity.Add(1);
                        cost.Add(D[i,j-1] == D[i,j] ? 0 : 1);
                    }
                    if(j != W-1){
                        F.Add(i*W+j);
                        T.Add(i*W+(j+1));
                        capacity.Add(1);
                        cost.Add(D[i,j+1] == D[i,j] ? 0 : 1);
                    }
                }
                else{
                    T.Add(G);
                    F.Add(i*W+j);
                    capacity.Add(1);
                    cost.Add(0);
                }
            }
        }
        MinCostFlow Flow = new MinCostFlow(F.ToArray(),T.ToArray(),capacity.ToArray(),cost.ToArray(),G+1,S,G,H*W/2);
        sb.Append(Flow.res+"\n");
    }
}
class Edge{
    public Vertex to;
    public long capacity;
    public long cost;
    public Edge rev;
    public Edge(Vertex v,long ca,long co){
        to = v;
        capacity = ca;
        cost = co;
    }
}
class Vertex{
    public bool finished;
    public long cost;
    public long h;
    public Vertex fromv;
    public Edge frome;
    public List<Edge> edges;
    public void AddEdge(Edge e){
        edges.Add(e);
    }
    public Vertex(){
        edges = new List<Edge>();
        finished = false;
        cost = -1;
    }
}
struct Data{
    public Vertex v;
    public long cost;
    public Data(Vertex v0,long c){
        v = v0;
        cost = c;
    }
}
class MinCostFlow{
    Vertex[] point;
    Vertex S;
    Vertex G;
    public long res;
    int E;
    const long INF = 1000000000000000;
    public MinCostFlow(int[] f,int[] t,long[] capacity,long[] cost,int n,int s,int g,long flow){
        point = new Vertex[n];
        for(int i=0;i<n;i++){
            point[i] = new Vertex();
        }
        E = f.Length;
        for(int i=0;i<E;i++){
            point[f[i]].AddEdge(new Edge(point[t[i]],capacity[i],cost[i]));
            point[t[i]].AddEdge(new Edge(point[f[i]],0,-cost[i]));
            point[f[i]].edges[point[f[i]].edges.Count-1].rev = point[t[i]].edges[point[t[i]].edges.Count-1];
            point[t[i]].edges[point[t[i]].edges.Count-1].rev = point[f[i]].edges[point[f[i]].edges.Count-1];
        }
        S = point[s];
        G = point[g];
        res = 0;
        while(true){
            Heap H = new Heap(2*E+1);
            S.cost = 0;
            H.push(new Data(S,0));
            while(!H.Empty()){
                Data D = H.pop();
                Vertex V = D.v;
                if(V.finished){
                    continue;
                }
                V.finished = true;
                for(int i=0;i<V.edges.Count;i++){
                    if(V.edges[i].capacity == 0){
                        continue;
                    }
                    Vertex T = V.edges[i].to;
                    if(T.cost == -1 || T.cost > V.cost + V.edges[i].cost + V.h - T.h){
                        T.cost = V.cost + V.edges[i].cost + V.h - T.h;
                        T.fromv = V;
                        T.frome = V.edges[i];
                        H.push(new Data(T,T.cost));
                    }
                }
            }
            if(G.cost == -1){
                res = -1;
                break;
            }
            for(int i=0;i<n;i++){
                point[i].h += point[i].cost;
                point[i].cost = -1;
                point[i].finished = false;
            }
            long d = flow;
            for(Vertex V = G;V != S;V = V.fromv){
                d = Math.Min(d,V.frome.capacity);
            }
            res += d*G.h;
            for(Vertex V = G;V != S;V = V.fromv){
                V.frome.capacity -= d;
                V.frome.rev.capacity += d;
            }
            flow -= d;
            if(flow == 0){
                break;
            }
        }
    }
}
class Heap{
    public int size;
    Data[] obj;
    public Heap(int maxsize){
        size = 0;
        obj = new Data[maxsize];
    }
    public void push(Data a){
        int i = size;
        size++;
        while(i > 0){
            int p = (i - 1)/2;
            if(obj[p].cost <= a.cost){
                obj[i] = a;
                break;
            }
            obj[i] = obj[p];
            i = p;
        }
        if(i == 0){
            obj[0] = a;
        }
    }
    public bool Empty(){
        return size == 0;
    }
    public Data pop(){
        Data t = obj[0];
        int i = 0;
        size--;
        while(2*i+1 < size){
            int p = 2*i+1;
            if(p+1 < size && obj[p+1].cost < obj[p].cost){
                p++;
            }
            if(obj[p].cost < obj[size].cost){
                obj[i] = obj[p];
                i = p;
            }
            else{
                obj[i] = obj[size];
                break;
            }
        }
        if(2*i+1 >= size){
            obj[i] = obj[size];
        }
        return t;
    }
}


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

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().solve();
        return 0;
    }

    void solve()
    {
        Scanner cin = new Scanner();

        int h = cin.nextInt();
        int w = cin.nextInt();
        int[,] board = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                board[i, j] = cin.nextInt();
            }
        }

        int MAX = 1 << w;
        int[] dp = new int[MAX];
        for (int i = 0; i < MAX; i++)
        {
            dp[i] = 1 << 16;
        }
        dp[0] = 0;

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                int[] nextdp = new int[MAX];
                for (int k = 0; k < MAX; k++)
                {
                    nextdp[k] = 1 << 16;
                }

                for (int k = 0; k < MAX; k++)
                {
                    if (k % 2 == 0)
                    {
                        if (j != w - 1)
                        {
                            int add = 0;
                            if (board[i, j] != board[i, j + 1]) add = 1;
                            int next = k / 2 + 1;
                            nextdp[next] = Math.Min(nextdp[next], dp[k] + add);
                        }
                        if (i != h - 1)
                        {
                            int add = 0;
                            if (board[i, j] != board[i + 1, j]) add = 1;
                            int next = k / 2 + (1 << (w - 1));
                            nextdp[next] = Math.Min(nextdp[next], dp[k] + add);
                        }
                    }
                    else
                    {
                        nextdp[k / 2] = Math.Min(nextdp[k / 2], dp[k]);
                    }
                }
                dp = nextdp;
            }
        }
        Console.WriteLine(dp[0]);

    }

}

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


using System;
using System.Collections.Generic;
using System.Linq;
class Solver
{
    void Solve()
    {
        var n = sc.Integer();
        var m = sc.Integer();
        var hori = sc.ScanLine().Select(x => x == '>' ? 1 : -1).ToArray();
        var ver = sc.ScanLine().Select(x => x == 'v' ? 1 : -1).ToArray();
        for (int r = 0; r < n; r++)
        {
            for (int c = 0; c < m; c++)
            {
                var used = new bool[n, m];
                var qr = new Queue<int>();
                var qc = new Queue<int>();
                qr.Enqueue(r);
                qc.Enqueue(c);
                while (qr.Any())
                {
                    var pr = qr.Dequeue();
                    var pc = qc.Dequeue();
                    if (used[pr, pc]) continue;
                    used[pr, pc] = true;
                    //horizon
                    {
                        var nc = pc + hori[pr];
                        if (nc < 0 || nc >= m || used[pr, nc]) { }
                        else
                        {
                            qr.Enqueue(pr);
                            qc.Enqueue(nc);
                        }

                    }
                    //vertical
                    {
                        var nr = pr + ver[pc];
                        if (nr < 0 || nr >= n || used[nr, pc]) { }
                        else
                        {
                            qr.Enqueue(nr);
                            qc.Enqueue(pc);
                        }
                    }
                }
                for (int i = 0; i < n; i++)
                    for (int j = 0; j < m; j++)
                        if (!used[i, j])
                        {
                            Printer.PrintLine("NO");
                            return;
                        }
            }
        }
        Printer.PrintLine("YES");
    }

    static void Main()
    {
#if DEBUG
        var ostream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        Console.ReadKey(true);
#endif
    }
    _Scanner sc = new _Scanner();

}

static public class Printer
{
    static readonly private System.IO.TextWriter writer;
    static readonly private System.Globalization.CultureInfo info;
    static string Separator { get; set; }
    static Printer()
    {
        writer = Console.Out;
        info = System.Globalization.CultureInfo.InvariantCulture;
        Separator = " ";
    }

    static public void Print(int num) { writer.Write(num.ToString(info)); }
    static public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(long num) { writer.Write(num.ToString(info)); }
    static public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(double num) { writer.Write(num.ToString(info)); }
    static public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(string str) { writer.Write(str); }
    static public void Print(string format, params object[] arg) { writer.Write(format, arg); }
    static public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
    static public void Print(params object[] arg)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in arg)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.Write(res.ToString(0, res.Length - Separator.Length));
    }
    static public void Print<T>(IEnumerable<T> sources)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in sources)
        {
            res.AppendFormat(info, "{0}", x);
            if (string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.Write(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(string str) { writer.WriteLine(str); }
    static public void PrintLine(string format, params object[] arg) { writer.WriteLine(format, arg); }
    static public void PrintLine(IEnumerable<char> sources) { writer.WriteLine(sources.AsString()); }
    static public void PrintLine(params object[] arg)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in arg)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine<T>(IEnumerable<T> sources)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in sources)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine(System.Linq.Expressions.Expression<Func<string, object>> ex)
    {
        var res = ex.Parameters[0];
        writer.WriteLine(res.Name);
    }
}
public class _Scanner
{
    readonly private System.Globalization.CultureInfo info;
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public _Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        this.reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();
        this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        var size = this.buffer.Length - this.position;
        var ar = new string[size];
        Array.Copy(this.buffer, position, ar, 0, size);
        return ar;

    }

    public string ScanLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.StringBuilder();
            for (; this.position < buffer.Length; this.position++)
            {
                sb.Append(this.buffer[this.position]);
                sb.Append(' ');
            }
            return sb.ToString();
        }
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
        {
            ar[i] = this.Scan();
        }
        return ar;
    }

    public int Integer()
    {
        return int.Parse(this.Scan(), info);
    }
    public long Long()
    {
        return long.Parse(this.Scan(), info);
    }
    public double Double()
    {
        return double.Parse(this.Scan(), info);
    }
    public double Double(string str)
    {
        return double.Parse(str, info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
    static public IEnumerable<T> Enumerate<T>(this int count, Func<int, T> selector)
    {
        return Enumerable.Range(0, count).Select(x => selector(x));
    }
}


using System;

namespace _475B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            str[0] = Console.ReadLine();
            str[1] = Console.ReadLine();
            string result = String.Join(null, str[0][0], str[0][n - 1], str[1][0], str[1][m - 1]);
            if (result.Equals("<>v^") || result.Equals("><^v"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

// you can write to stdout for debugging purposes, e.g.
// Console.WriteLine("this is a debug message");

//mcs HelloWorld.cs
//mono HelloWorld.exe
public class HelloWorld {

	public static void Main(string[] args)
	{
		var arr = Array.ConvertAll(Console.ReadLine().Split(' '), t=> Convert.ToInt32(t));
		solve(arr);
		//tests();
	}

	public static void solve(int[] ar)
	{
		var  n = ar.Length;

		long max= 0;
		for (var ind = 0; ind < n; ind++)
		{
			if (ar[ind] == 0)
				continue;

			var arr = new int[n];
			Array.Copy(ar,arr,n);
			var p = arr[ind] / 14;
			var k = arr[ind] % 14;
			arr[ind] = 0;
			if (p > 0)
			{
				for (var i = 0; i < n; i++)
				{
					arr[i] = arr[i] + p;
				}
			}
			//Console.WriteLine( p + " " + k);
			if (k > 0)
			{
				for (var i = ind + 1; i < Math.Min(n, ind + k + 1); i++)
				{
					arr[i] += 1;
				}
				if (ind + k + 1 > n)
				{
					for (var i = 0; i <= ind + k - n; i++)
					{
						arr[i] += 1;
					}
				}
			}
			long sum = 0;
			for (var i = 0; i < n; i++)
			{
				//Console.Write(arr[i] + " ");
				if (arr[i] % 2 == 0)
				{
					sum+= arr[i];
				}
			}
			max = Math.Max(sum, max);
		}
		Console.WriteLine(max);

	}

}


using System;

namespace _a
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            long[] Arr = new long[14];
            string[] Input = Console.ReadLine().Split();
            for (int i = 0; i < 14; i++) Arr[i] = Convert.ToInt64(Input[i]);

            long Max = 0;
            for (int i = 0; i < 14; i++)
            {
                if (Arr[i] != 0)
                {
                    long[] ArrW = new long[14];
                    Array.Copy(Arr, ArrW, 14);
                    long K = ArrW[i % 14] % 14;
                    long T = ArrW[i % 14];
                    ArrW[i % 14] = 0;
                    for (int j = 0; j < 14; j++)
                    {
                        ArrW[(i + j + 1) % 14] += T / 14 ;
                    }

                    for (int j = 1; j <= K; j++)
                    {
                        ArrW[(i + j) % 14]++;
                    }

                    long Res = 0;
                    for (int j = 0; j < 14; j++)
                    {
                        if (ArrW[j] % 2 == 0)
                        {
                            Res += ArrW[j];
                        }
                    }

                    if (Res > Max) Max = Res;
                }
            }

            Console.WriteLine(Max);
        }
    }
}


#define EXTENDSTACKSIZE

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

namespace CF
{
    internal class Program
    {
        private const int stackSize = 64 * 1024 * 1024;

        private static void Run()
        {
            using (var sr = new InputReader(Console.In))
//            using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
//            using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }

        private static void Main(string[] args)
        {
#if EXTENDSTACKSIZE
            var threadStart = new ThreadStart(Run);
            var thread = new Thread(threadStart, stackSize);
            thread.Start();
            thread.Join();
#else
            Run();
#endif
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            var s1 = sr.NextString().Split(new[] {':'});
            var h1 = int.Parse(s1[0]);
            var m1 = int.Parse(s1[1]);
            var s2 = sr.NextString().Split(new[] {':'});
            var h2 = int.Parse(s2[0]);
            var m2 = int.Parse(s2[1]);
            var d1 = new DateTime(1, 1, 1, h1, m1, 0);
            var d2 = new DateTime(1, 1, 1, h2, m2, 0);
            var d = (d2 - d1).Ticks / 2;
            var d3 = d1.AddTicks(d);
            var h = d3.Hour.ToString();
            var m = d3.Minute.ToString();
            if (h.Length == 1)
            {
                h = "0" + h;
            }

            if (m.Length == 1)
            {
                m = "0" + m;
            }
            sw.WriteLine(h + ":" + m);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


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

namespace Task1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> time0 = Console.ReadLine().Split(':').ToList().ConvertAll(int.Parse);
            int minutsBegin = 60 * time0[0] + time0[1];
            List<int> timeK = Console.ReadLine().Split(':').ToList().ConvertAll(int.Parse);
            int minutsEnd = 60 * timeK[0] + timeK[1];
            int minuteAverage = (minutsBegin + minutsEnd) / 2;
            int hourEnd = minuteAverage / 60;
            int minuteEnd = minuteAverage % 60;
            Console.WriteLine(String.Format("{0:00}", hourEnd)+":"+ String.Format("{0:00}", minuteEnd));
        }
    }
}


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

namespace ConsoleApplication15
{
    class Program
    {
        static int Main(string[] args)
        {
            string[] inArr = Console.ReadLine().Split(' ');
            int n = int.Parse(inArr[0]),
                m = int.Parse(inArr[1]);
            int[] originalArr = new int[n];
            for (int i = 0; i < n; i++)
                originalArr[i] = i + 1;
            string[] allArrays= new string[factorial(n)];
            for (int i=0; i<factorial(n); i++)
            {
                allArrays[i] = getNumbers(originalArr, i);
            }
            int[] allFp = new int[allArrays.Length];
            int maxFp = 0;
            for (int cur = 0; cur < allArrays.Length; cur++)
            {
                int fP = 0;
                string[] p = allArrays[cur].Split(' ');
                for (int i = 0; i < n; i++)
                {
                    for (int j = i; j < n; j++)
                    {
                        int min = int.Parse(p[i]);
                        for (int x = i; x <= j; x++)
                        {
                            if (int.Parse(p[x]) < min)
                                min = int.Parse(p[x]);
                        }
                        fP += min;
                    }
                }
                allFp[cur] = fP;
                if (fP > maxFp) maxFp = fP;
            }
            int curM = 1;
            for (int i = 0; i < allArrays.Length; i++)
            {
                if (allFp[i] == maxFp)
                {

                    if (curM == m)
                    {
                        Console.Write(allArrays[i]);
                        break;
                    }
                    curM++;
                }
            }
            return 0;
        }
        static string getNumbers(int[] nums, long cur)
        {

            int size = nums.Length;
            if (size == 1) return Convert.ToString(nums[0]);
            long amount = factorial(size);
            long ind = (long)(cur / (amount / size));
            int[] newNums = new int[size - 1];
            int Tx = 0;
            for (int x = 0; x < size; x++)
            {
                if (x == ind)
                    continue;
                newNums[Tx] = nums[x];
                Tx++;
            }
            return nums[ind] + " " + getNumbers(newNums, (cur - (amount / size) * ind));

        }
        static long factorial(int n)
        {
            return n <= 1 ? 1 : n * factorial(n - 1);
        }
    }
}


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

namespace RocketB
{
    class Program
    {

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var strs = str.Split(' ');
            int n = 0;
            long m = 0;
            int.TryParse(strs[0], out n);
            long.TryParse(strs[1], out m);
            --m;

            int[] array = new int[n];

            var tempm = m;
            for (int i = 0; i < n; i++)
            {
                array[i] = (int)(tempm % 2);
                tempm /= 2;
            }

            for (int i = 0; i < n - 1; i ++)
            {
                if (array[n - 1 - i - 1] == 0)
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }
                else
                {
                    //Console.Write(i + 1 );
                    //Console.Write(" ");
                }

            }

           // if (p2 > 0)
            {
                Console.Write(n - 1 + 1 );
                Console.Write(" ");
            }

            for (int i = n - 2; i >= 0; i--)
            {
                if (array[n - 1 - i -1] == 0)
                {
                    //Console.Write(i + 1);
                    //Console.Write(" ");
                }
                else
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }

            }
            Console.WriteLine("");

        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace olimp
{

    class Node
    {
        public List<Node> Roads;
        public List<Node> ClosedRoads;
        public int Id,Mark;
    }

    static class Program
    {
        private static void Main()
        {
            string[] s =  Console.ReadLine().Split(' ');
            int[] a = new[]{ int.Parse(s[0]), int.Parse(s[1]), int.Parse(s[2]) };
            Array.Sort(a);
            int r, g, b;
            r = a[0];
            g = a[1];
            b = a[2];
            int ans = r + (g-r)/3 + (b-r)/3;
            int ans2 = b / 3 + g / 3 + Math.Min(r, Math.Min(b % 3, g % 3)) + (r - Math.Min(r, Math.Min(b % 3, g % 3)))/3;
            ans = Math.Max(ans, ans2);
            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static void ReadIntPair(out int a1, out int a2)
        {
            string[] s = Console.ReadLine().Split(' ');
            a1 = int.Parse(s[0]);
            a2 = int.Parse(s[1]);
        }

        static long ReadNextInt()
        {
            char c;
            StringBuilder builder = new StringBuilder(4);
            while (char.IsDigit(c = (char) Console.Read()) || c == '-'||c == '\r' || c == '\n')
            {
                if (c == '\r' || c == '\n')
                    continue;
                builder.Append(c);
            }
            return long.Parse(builder.ToString());
        }

        static int Sum1(int n)
        {
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                sum += (int)(Math.Pow(-1, i)*Math.Pow(n - i, 2));
            }
            return sum;
        }

        static int Sum2(int n)
        {
            return (n*(n+1))/2;
        }

        static double Log10(double x)
        {
            int n = CalnN((int) x);
            double val = n;
            double last = x;
            for (int i = 1; i <= sizeof(double) * 8; i++)
            {
                last = last*last;
                if (last >= 10)
                {
                    val += 1/Math.Pow(2, i);
                    last /= 10;
                }
            }
            return val;
        }

        static int CalnN(int x)
        {
            int i = 0;
            for (; Math.Pow(x, i + 1) < x; i++)
            {
            }
            return i;
        }
    }
}


using System;

namespace Flowers
{
    class Flowers
    {
        static void Main(string[] args)
        {
            string[] rgb = Console.ReadLine().Split(' ');
            long r = long.Parse(rgb[0]);
            long g = long.Parse(rgb[1]);
            long b = long.Parse(rgb[2]);

            long rm = r % 3;
            long gm = g % 3;
            long bm = b % 3;
            if (rm == 0 && r > 0) rm = 3;
            if (gm == 0 && g > 0) gm = 3;
            if (bm == 0 && b > 0) bm = 3;

            long f = (r - rm) / 3 + (g - gm) / 3 + (b - bm) / 3;

            long min = Math.Min(rm, Math.Min(bm, gm));
            long thr = (rm == 3 ? 1 : 0) + (gm == 3 ? 1 : 0) + (bm == 3 ? 1 : 0);
            f += Math.Max(min, thr);

            Console.WriteLine(f);
        }
    }
}


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

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

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

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

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

        private static Stopwatch _stopwatch = new Stopwatch();

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

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

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

        public static string Check(string s)
        {
            string letters = "aeiouy";

            while (true)
            {
                bool used = false;

                for (int i = 0; i < s.Length - 1; i++)
                {
                    if (letters.Contains(s[i].ToString()) && letters.Contains(s[i + 1].ToString()))
                    {
                        s = s.Remove(i + 1, 1);

                        used = true;
                    }
                }

                if (!used)
                {
                    return s;
                }
            }
        }

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

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

            return _curLine[_curTokenIdx++];
        }

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

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

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int p = a[0];
            int y = a[1];

            for (int i = y; i > p; i--)
            {
                bool ok = true;

                for (int j = 2; j <= p && j * j <= i; j++)
                {
                    if (i % j == 0)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(-1);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

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

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

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

            Console.ReadKey();
#endif

        }

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

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

                else
                {
                    break;
                }

            }

            return countZero;
        }

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

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

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

        private static string StreamReader()
        {

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

        }

        private static void StreamWriter(string text)
        {

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

        }

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

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

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

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

            }
            return 0;

        }

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

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

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

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

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

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

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

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

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

            return arr;
        }
    }
}


using System;

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

            int p = int.Parse(tokens[0]);
            int y = int.Parse(tokens[1]);

            for (; y > p; y--)
            {
                bool suitable = true;

                for (int i = 2; i <= p && i <= y / i; i++)
                {
                    if (y % i == 0)
                    {
                        suitable = false;
                        break;
                    }
                }

                if (suitable)
                {
                    Console.WriteLine(y);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }
}


/*
csc -debug B.cs && mono --debug B.exe <<< "6
5 10 2 3 14 5"
*/

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

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
    }

    public static void SolveCodeForces() {
        var sc = new Scanner();

        var n = sc.NextInt();
        var A = sc.UlongArray().OrderBy(a => a).ToArray();

        var cnt = 0ul;
        for (var i = 0; i < n/2; i++) {
            cnt += A[2*i+1] - A[2*i];
        }

        System.Console.WriteLine(cnt);
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static T ElementWithMax<T>(this IEnumerable<T> seq, Func<T, long> func) {
        var bi = default(T);
        var bv = long.MinValue;
        foreach (var item in seq) {
            var v = func(item);
            if (v > bv) {
                bi = item;
                bv = v;
            }
        }
        return bi;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

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

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

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray() {
        var array = Array();
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


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

namespace Graph
{
    public class Program
    {
        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader("in.txt"));
            Console.SetOut(new StreamWriter("out.txt") { AutoFlush = true });
#endif
            var n = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToList();

            array.Sort();

            int result = 0;
            for (int i = 0; i < n; i+=2)
            {
                result += array[i + 1] - array[i];
            }
            Console.WriteLine(result);
        }
    }
}


using System;
using System.Collections.Generic;

class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		Dictionary<int, int> a = new Dictionary<int, int>();
		for (int i = 1; i <= 5; i++)
		{
			a[i] = 0;
		}
		string s = Console.ReadLine();
		for (int i = 0; i < s.Length; i += 2)
		{
			a[int.Parse(s[i].ToString())]++;
		}
		Dictionary<int, int> b = new Dictionary<int, int>();
		for (int i = 1; i <= 5; i++)
		{
			b[i] = 0;
		}
		s = Console.ReadLine();
		for (int i = 0; i < s.Length; i += 2)
		{
			b[int.Parse(s[i].ToString())]++;
		}
		int counter = 0;
		for (int i = 1; i <= 5; i++)
		{
			if ((a[i] + b[i]) % 2 == 0)
			{
				if (a[i] > b[i])
				{
					counter += (a[i] - b[i]) / 2;
				}
			}
			else
			{
				Console.WriteLine("-1");
				return;
			}
		}
		Console.WriteLine(counter);
	}
}


using System;
using System.Linq;

static class P {
    static int[] ToIntArray(this string s) { return s.Split().Select(int.Parse).ToArray(); }
    static void Main() {
        int n = int.Parse(Console.ReadLine()), r = 0;
        int[] A = Console.ReadLine().ToIntArray(),
            B = Console.ReadLine().ToIntArray();

        var all = A.Concat(B).GroupBy(x => x)
            .Select(x => new { Key = x.Key, Count = x.Count() });

        foreach (var info in all) {
            if (info.Count % 2 != 0) {
                Console.WriteLine(-1);
                return;
            }
        }

        var grA = A.GroupBy(x => x)
            .Select(x => new { Key = x.Key, Count = x.Count() });

        foreach (var info in all) {
            var val = info.Count / 2;
            var found = grA.FirstOrDefault(x => x.Key == info.Key);

            if (found != null) {
                if (found.Count > val) {
                    r += found.Count - val;
                }
            }
        }

        Console.WriteLine(r);
    }
}


using System;

namespace ConsoleApplication2
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string a = Console.ReadLine();
            int end = 0;;
            for (int i = 0; i < n; i++)
            {
                if (a[i] == '+')
                {
                    end++;
                }
                else
                {
                    end--;
                }

                if (end < 0)
                {
                    end++;
                }
            }

            int s = end;
            Console.WriteLine(s);
            Console.ReadLine();
        }
    }
}


// Problem: 1159A - A pile of stones
// Author: Gusztav Szmolik

using System;

class APileOfStones
    {
    public static int Main ()
        {
        string line = Console.ReadLine ();
        if (line == null)
            return -1;
        string[] words = line.Split ();
        if (words.Length != 1)
            return -1;
        byte n;
        if (!Byte.TryParse (words[0], out n))
            return -1;
        if (n < 1 || n > 100)
            return -1;
        line = Console.ReadLine ();
        if (line == null)
            return -1;
        words = line.Split ();
        if (words.Length != 1)
            return -1;
        string s = words[0];
        if (s.Length != n)
            return -1;
        byte ans = 0;
        char c;
        for (byte i = 0; i < n; i++)
            {
            c = s[i];
            if (c != '-' && c != '+')
                return -1;
            if (c == '-' && ans > 0)
                ans--;
            else if (c == '+')
                ans++;
            }
        Console.WriteLine (ans);
        return 0;
        }
    }


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

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

            var input = Console.ReadLine().Split('e');
            string a = input[0];
            string exp = input[1];
            int b = int.Parse(exp);

            if (a == "0.0")
            {
                Console.WriteLine(0);
                return;
            }

            if (a.First() == '0')
            {
                Console.WriteLine(a);
                return;
            }

            int pointIndex = a.IndexOf('.');

            if (b == 0)
            {
                if (a.Length - (pointIndex + 1) == 1 && a.Last() == '0')
                {
                    Console.WriteLine(a.Substring(0, pointIndex));
                    return;
                }
            }

            if (pointIndex != -1)
            {

                a = a.Remove(pointIndex, 1);
                if (pointIndex + b < a.Length)
                {
                    pointIndex += b;
                    a = a.Insert(pointIndex, ".");
                }
                else
                {
                    int extend = pointIndex + b - a.Length;
                    if ( extend > 0)
                    {
                        char[] zero = new char[extend];
                        for (int i = 0; i < extend; i++)
			            {
			                zero[i] = '0';
			            }

                        a += new string(zero);
                    }
                }

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


using System;

class Round362P2{
	static string StripFrontZero(string str){
		string ret = "";
		bool fl = true;
		for(int i=0;i<str.Length;i++){
			if(fl && str[i] == '0')
				continue;
			if(str[i] != '0'){
				fl = false;
			}
			if(!fl){
				ret += str[i];
			}
		}
		return ret;
	}
	public static void Main(string[] args){
		string line = Console.ReadLine();
		string bd = "",ad = "" ,pow = "";
		bool dfl = false;
		bool efl = false;
		int ipow = 0;
		for(int i=0;i<line.Length;i++){
			if(line[i] == '.'){
				dfl = true;
				continue;
			}
			if(line[i] == 'e'){
				efl = true;
				continue;
			}
			if(dfl == false){
				bd += line[i];
			}
			else if(dfl == true && efl == false){
				ad += line[i];
			}
			else if(dfl == true && efl == true){
				pow += line[i];
				ipow = ipow*10+(int)line[i]-48;
			}
		}
		string nad = "";
		//not int
		if(ipow < ad.Length){
			nad = ad.Substring(0,ipow)+"."+ad.Substring(ipow,ad.Length-ipow);
			//Console.WriteLine("nad: "+nad);
		}
		else{
			nad = ad;
			for(int i=0;i<ipow - ad.Length;i++)
				nad += "0";
		}
		string ans = "";
		if(nad.CompareTo(".0") == 0){
			ans = bd;
		}
		else if(bd.CompareTo("0") != 0){
			ans  = bd+nad;
		}
		else{
			string temp = StripFrontZero(nad);
			if(temp[0] == '.')
				ans = '0'+temp;
			else ans  = temp;
		}
		Console.WriteLine(ans);
	}
}


using System;
using System.Linq;

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

            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);

            var isPrime = new bool[n + 1];

            for (int i = 2; i < isPrime.Length; i++)
            {
                isPrime[i] = true;
            }

            for (int i = 2; i < isPrime.Length; i++)
            {
                if (isPrime[i])
                {
                    for (int j = 2 * i; j < isPrime.Length; j += i)
                    {
                        isPrime[j] = false;
                    }
                }
            }

            var primes = Enumerable.Range(0, isPrime.Length).Where(i => isPrime[i]).ToArray();
            Console.WriteLine(Enumerable.Range(1, primes.Length - 1).Select(i => primes[i - 1] + primes[i] + 1).Count(p => p <= n && isPrime[p]) >= k ? "YES" : "NO");
        }
    }
}


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

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

            List<int> primes = new List<int>();
            int[] temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = temp[0], k = temp[1];
            for(int i = 2; i <= n; i++)
            {
                if (IsPrime(i))
                    primes.Add(i);
            }
            int counter = 0;
            for(int i = 0; i < primes.Count - 1; i++)
            {
                int t = primes[i] + primes[i + 1] + 1;
                if (IsPrime(t) && t <= n)
                    counter++;
                if (t > n || counter >= k) break;
            }
            Console.WriteLine((counter >= k) ? "YES" : "NO");

        }

        static bool IsPrime(int num)
        {
            if(num==2)return true;
            if (num < 2 || num % 2 == 0) return false;
            int limit = Convert.ToInt32( Math.Sqrt(num));
            for(int i = 3; i <= limit; i += 2)
            {
                if (num % i == 0) return false;
            }
            return true;
        }
    }
}


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

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public int Second;

			public int Third;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First > y.First || (x.First == y.First && x.Second < y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;
			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string ReadString()
		{
			return Console.ReadLine();
		}

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Vertex
		{
			public int Was;

			public List<Pair> Edges;
		}

		public static List<List<Vertex>> Graph = new List<List<Vertex>>();

/*		public static bool Dfs(int x, int y, int prevx, int prevy)
		{
			Graph[x][y].Was = 1;
			var result = false;
			foreach (var t in Graph[x][y].Edges)
			{
				if (Graph[t.First][t.Second].Was == 0)
					result |= Dfs(t.First, t.Second, x, y);
				else if (t.First != prevx || t.Second != prevy)
					return true;
			}

			return result;
		}*/

		public static bool IsPrime(int x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		private static void Main()
		{
			var s = ReadString();
			var ans = 0;
			var curO = s[0];
			var curCt = 1;
			var i = 1;
			while (i < s.Length)
			{
				if (s[i] != curO)
				{
					ans++;
					curO = s[i];
					curCt = 1;
				}
				else
				{
					if (curCt == 5)
					{
						ans++;
						curCt = 1;
					}
					else
					{
						curCt++;
					}
				}
				i++;
			}
			ans++;
			Console.WriteLine(ans);
			Console.ReadLine();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        var cp = ReadToken();
        var n = 1;
        var c = 0;
        for (int i = 0; i < cp.Length - 1; i++)
        {
            if (cp[i] == cp[i + 1])
            {
                c++;
                if (c == 5)
                {
                    n++;
                    c = 0;
                }
            }
            else
            {
                n++;
                c = 0;
            }
        }
        Write(n);
        reader.Close();
        writer.Close();
    }
    #region Read / Write

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

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

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

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

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

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

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

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

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }
    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }
    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write<T>(params T[] array)
    {
        WriteArray(array);
    }

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


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(GetMax(n, n));
        }

        private static long GetMax(int i, int j)
        {
            if (i == 1 || j == 1)
                return 1;
            return GetMax(i - 1, j) + GetMax(i, j - 1);
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
class Problem
{
    static void Main()
    {
        int n = Convert.ToInt32( Console.ReadLine() );
        Console.WriteLine( kq( n - 1) );
    }

    private static string kq(int p)
    {
        long str = 1;
        for(int i = p + 1 ; i <= 2 * p ; i++)
            str*= i;
        for(int i = 1 ; i <= p ; i++)
            str /= i;
        return str.ToString();
    }
}


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

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

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

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

			long a1 = inputs1[0];
			long a2 = inputs1[1];

			var min = Math.Min(a1, a2);
			var max = a1 + a2 - min;

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

			long count = 0;
			while (min > 0 && max > 0)
			{
				while (max > 2)
				{
					min++;
					max -= 2;
					count++;
				}

				var temp = Math.Min(min, max);
				max = min + max - temp;
				min = temp;

				if (max == 1 || max == 2)
				{
					count++;
					break;
				}
			}

			Console.WriteLine(count);
		}

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

			public int Points { get; set; }

			public int GoalsFor { get; set; }

			public int GoalsAgainst { get; set; }
		}

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


using System;
class Program
    {
        static void Main(string[] args)
        {
            string [] input = Console.In.ReadLine().Split(new char[] { ' ', '\n', '\r', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            input = null;
            int ans = (a + b - (Math.Abs(a - b) % 3 == 0 ? 3 : 2));
            Console.WriteLine(ans>0?ans:0);
        }
    }


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

namespace Task
{
    #region MyIo

    class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

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

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

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

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

            outputStream.WriteLine();
        }

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

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

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }
    #endregion

    class Program
    {
        #region Program

        readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion

        void Solve()
        {
            var a = io.NextInt();
            var b = io.NextInt();

            for (int i = a + 1; i <= 200000 + b; i++)
            {
                if (CalcGood(i) == b)
                {
                    io.Print(i);
                    break;
                }
            }
        }

        private int CalcGood(int i)
        {
            int res = 0;
            int step = 1;

            while (i != 0)
            {
                int ost = i % 10;
                i /= 10;

                if (ost == 4 || ost == 7)
                {
                    res += ost * step;
                    step *= 10;
                }
            }

            return res;
        }

    }
}


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

namespace CodeForceContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ').Select(ss => int.Parse(ss)).ToArray();
            //var s = "401 4".Split(' ').Select(ss => int.Parse(ss)).ToArray();
            var a = s[0];
            var b = s[1];
            var res = a + 1;
            for (; ; )
            {
                if(TakeMask(res)==b)
                {
                    break;
                }
                res++;
            }
            Console.WriteLine(res);
        }
        static int TakeMask(int a)
        {
            var e = a.ToString();
            var list = new List<char>();
            foreach (var i in e)
            {
                if(i=='4' ||i=='7')list.Add(i);
            }
            if (list.Count > 0)
                return int.Parse(String.Join("", list.Select(s => s.ToString()).ToArray()));
            else return 0;
        }
    }

}


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

class Program
{
    static void Main(string[] args)
    {
        string [] Input = Console.ReadLine().Split();
        int Parent = Int32.Parse(Input[0]);
        int Childs = Int32.Parse(Input[1]);
        int max, min;

        if (Childs == 0)
            max = Parent;
        else
            max = Parent + Childs - 1;
        if (Childs >= Parent) min = Parent + (Childs - Parent);
        else
            min = Parent;

        if (Parent == 0 && Childs != 0)
            Console.Write("Impossible");
        else
            Console.Write("{0} {1}", min, max);
    }
}


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

namespace Vasia
{
    class Program
    {
        static void Main(string[] args)
        {
            long n, m;

            string s;
            string[] ss;

            s = Console.ReadLine();
            ss = s.Split();
            n = Convert.ToInt32(ss[0]);
            m = Convert.ToInt32(ss[1]);

            if (n == 0 & m == 0)
            {
                Console.WriteLine("{0} {1}", 0, 0);
                return;
            }

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

            if(m == 0)
            {
                Console.WriteLine("{0} {1}", n, n);
                return;
            }

            if (n > m)
            {
                Console.WriteLine("{0} {1}", n, (n + m) - 1);
            }
            else
            {
                Console.WriteLine("{0} {1}", m, (n + m) - 1);
            }

        }
    }
}


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

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
            //using (var sr = new InputReader(new StreamReader("input.txt")))
            {
                var task = new Task();
                using (var sw = Console.Out)
                {
                    //using (var sw = new StreamWriter("output.txt")) {
                    task.Solve(sr, sw);
                    //Console.ReadKey();
                }
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var n = sr.NextInt32();
            var array = sr.ReadArrayOfInt32();
            if (n == 1) {
                sw.WriteLine("YES");
                return;
            }
            for (var i = 0; i < array.Length; i++) {
                for (var j = i; j < array.Length; j++) {
                    var can = true;
                    for (var k = 1; k <= i; k++) {
                        if (array[k] <= array[k - 1]) {
                            can = false;
                            break;
                        }
                    }
                    for (var k = i; k <= j; k++) {
                        if (array[k] != array[i]) {
                            can = false;
                            break;
                        }
                    }
                    for (var k = j + 1; k < array.Length; k++) {
                        if (array[k] >= array[k - 1]) {
                            can = false;
                            break;
                        }
                    }
                    if (can) {
                        sw.WriteLine("YES");
                        return;
                    }
                }
            }

            sw.WriteLine("NO");
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.Linq;

namespace Problem831A
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var a = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();

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

        static bool Check(int[] a)
        {
            int le = -1;
            int l = a.Length;
            int i = 0;
            if (l == 1)
                return true;

            while (i < l && a[i] > le)
            {
                le = a[i];
                i++;
            }
            if (i == l && a[l - 1] > a[l - 2])
                return true;

            if (a[i] == le)
            {
                while (i < l && a[i] == le)
                {
                    le = a[i];
                    i++;
                }

                if (i == l && a[l - 1] == a[l - 2])
                    return true;
            }
            le = a[i - 1];
            while (i < l && a[i] < le)
            {
                le = a[i];
                i++;
            }

            if (i != l)
                return false;

            return true;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static util;
using P = pair<int, int>;

class Program {
    static void Main(string[] args) {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        var solver = new Solver(sw);
        // var t = new Thread(solver.solve, 1 << 28); // 256 MB
        // t.Start();
        // t.Join();
        solver.solve();
        sw.Flush();
    }
}

class Solver {
    StreamWriter sw;
    Scan sc;
    void Prt(string a) => sw.WriteLine(a);
    void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
    void Prt(params object[] a) => Prt(string.Join(" ", a));
    public Solver(StreamWriter sw) {
        this.sw = sw;
        this.sc = new Scan();
    }

    public void solve() {
        var s = sc.Str;
        var a = s.Select(x => x - 'A').ToArray();
        for (int i = 0; i + 2 < a.Length; i++)
        {
            if (a[i + 2] != (a[i] + a[i + 1]) % 26) {
                Prt("NO");
                return;
            }
        }
        Prt("YES");

    }
}

class pair<T, U> : IComparable<pair<T, U>> {
    public T v1;
    public U v2;
    public pair() : this(default(T), default(U)) {}
    public pair(T v1, U v2) { this.v1 = v1; this.v2 = v2; }
    public int CompareTo(pair<T, U> a) {
        int c = Comparer<T>.Default.Compare(v1, a.v1);
        return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
    }
    public override string ToString() => $"{v1} {v2}";
    public void Deconstruct(out T a, out U b) { a = v1; b = v2; }
}
static class util {
    public static readonly int M = 1000000007;
    // public static readonly int M = 998244353;
    public static readonly long LM = 1L << 60;
    public static readonly double eps = 1e-11;
    public static void DBG(string a) => Console.Error.WriteLine(a);
    public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
    public static void DBG(params object[] a) => DBG(string.Join(" ", a));
    public static void Assert(params bool[] conds) {
        if (conds.Any(x => !x)) throw new Exception();
    }
    public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1, v2);
    public static int CompareList<T>(IList<T> a, IList<T> b) where T : IComparable<T> {
        for (int i = 0; i < a.Count && i < b.Count; i++)
            if (a[i].CompareTo(b[i]) != 0) return a[i].CompareTo(b[i]);
        return a.Count.CompareTo(b.Count);
    }
    public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
    public static readonly int[] dd = { 0, 1, 0, -1 };
    // static readonly string dstring = "RDLU";
    public static IEnumerable<P> adjacents(int i, int j) {
        for (int k = 0; k < 4; k++) yield return new P(i + dd[k], j + dd[k ^ 1]);
    }
    public static IEnumerable<P> adjacents(int i, int j, int h, int w) {
        for (int k = 0; k < 4; k++) if (inside(i + dd[k], j + dd[k ^ 1], h, w))
            yield return new P(i + dd[k], j + dd[k ^ 1]);
    }
    public static IEnumerable<P> adjacents(this P p) => adjacents(p.v1, p.v2);
    public static IEnumerable<P> adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2, h, w);
    public static IEnumerable<int> all_subset(this int p) {
        for (int i = 0; ; i = i - p & p) {
            yield return i;
            if (i == p) break;
        }
    }
    public static Dictionary<T, int> compress<T>(this IEnumerable<T> a)
        => a.Distinct().OrderBy(v => v).Select((v, i) => new { v, i }).ToDictionary(p => p.v, p => p.i);
    public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a)
        => compress(a.SelectMany(x => x));
    public static T[] inv<T>(this Dictionary<T, int> dic) {
        var res = new T[dic.Count];
        foreach (var item in dic) res[item.Value] = item.Key;
        return res;
    }
    public static void swap<T>(ref T a, ref T b) where T : struct { var t = a; a = b; b = t; }
    public static void swap<T>(this IList<T> a, int i, int j) where T : struct {
        var t = a[i]; a[i] = a[j]; a[j] = t;
    }
    public static T[] copy<T>(this IList<T> a) {
        var ret = new T[a.Count];
        for (int i = 0; i < a.Count; i++) ret[i] = a[i];
        return ret;
    }
}

class Scan {
    StreamReader sr;
    public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
    public Scan(string path) { sr = new StreamReader(path); }
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public string Str => ReadLine.Trim();
    public string ReadLine => sr.ReadLine();
    public pair<T, U> Pair<T, U>() {
        T a; U b;
        Multi(out a, out b);
        return new pair<T, U>(a, b);
    }
    public P P => Pair<int, int>();
    public int[] IntArr => StrArr.Select(int.Parse).ToArray();
    public long[] LongArr => StrArr.Select(long.Parse).ToArray();
    public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
    public string[] StrArr => Str.Split(new[]{' '}, StringSplitOptions.RemoveEmptyEntries);
    bool eq<T, U>() => typeof(T).Equals(typeof(U));
    T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
    T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
                       : eq<T, long>()   ? ct<T, long>(long.Parse(s))
                       : eq<T, double>() ? ct<T, double>(double.Parse(s))
                       : eq<T, char>()   ? ct<T, char>(s[0])
                                         : ct<T, string>(s);
    public void Multi<T>(out T a) => a = cv<T>(Str);
    public void Multi<T, U>(out T a, out U b) {
        var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]);
    }
    public void Multi<T, U, V>(out T a, out U b, out V c) {
        var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
    }
    public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
        var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
    }
    public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
        var ar = StrArr;
        a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]); e = cv<X>(ar[4]);
    }
    public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
        var ar = StrArr;
        a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        d = cv<W>(ar[3]); e = cv<X>(ar[4]); f = cv<Y>(ar[5]);
    }
}


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

namespace TestCodes
{
    class Problem
    {
        static void Main()
        {
            var w = ReadLine();

            if (string.IsNullOrEmpty(w))
                WriteLine("YES");
            else if (w.Length <= 2)
				WriteLine("YES");
            else if (((w[0] - 'A' + w[1] - 'A') % 26) == (w[2] - 'A'))
                WriteLine("YES");
            else
                WriteLine("NO");
        }
    }
}


using System;

namespace Skyscraper
{
    class Program
    {
        static void Main()
        {
            int t1 = Convert.ToInt32(Console.ReadLine());
            int t2 = Convert.ToInt32(Console.ReadLine());
            int t3 = Convert.ToInt32(Console.ReadLine());
            int t4 = Convert.ToInt32(Console.ReadLine());
            if (t3 > 0)
                if (t1 == 0)
                {
                    Console.WriteLine("0");
                    return;
        }
            if (t1 != t4)
            {
                Console.WriteLine("0");
                return;
            }
            Console.WriteLine("1");
        }
    }
}


/*
csc -debug A.cs && mono --debug A.exe <<< "3
1
4
3"
*/

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

public class HelloWorld {
    public static void SolveCodeForces() {
        var A = cin.NextInt();
        var B = cin.NextInt();
        var C = cin.NextInt();
        var D = cin.NextInt();

        if (A + C + D == 0) {
            System.Console.WriteLine(1);
            return;
        }

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

        if (D != A) {
            System.Console.WriteLine(0);
            return;
        }

        System.Console.WriteLine(1);
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // System.Console.Write(cout.ToString());
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

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

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

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}


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

    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ').ToList();
            long n = long.Parse(str[0]);
            long k = long.Parse(str[1]);
            int t = 0;
            int f = 0;

            long tmp = n;
            while(tmp % 2 == 0)
            {
                t++;
                tmp = tmp / 2;
            }
             tmp= n;
            while(tmp % 5 == 0)
            {
                f++;
                tmp /= 5;
            }

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

            long t1 = (k - t) > 0 ? k - t : 0;
            long f2 = (k - f) > 0 ? k - f : 0;

            long val = n * ((long) Math.Pow(2, t1)) * ((long) Math.Pow(5, f2));

            Console.WriteLine(val);

        }
    }


using System;

namespace CodeForces
{
	class A
	{
		static long gcd(long a, long b)
		{
			while (b != 0)
			{
				long temp = b;
				b = a % b;
				a = temp;
			}
			return a;
		}

		static long lcm(long m, long n)
		{
			return (m / gcd(m, n)) * n;
		}

		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] d = s.Split(' ');
			long n = long.Parse(d[0]);
			int k = int.Parse(d[1]);
			int div = (int) Math.Pow(10, k);

			Console.WriteLine(lcm(n, div));
		}
	}
}


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

class Program
{

    //////////////////////////////////////////////////
    void Solution()
    {
        var x = ri;
        var y = ri;
        long res = 0;
        if (y < x)
        {
            var buf = y;
            y = x;
            x = buf;
        }
        for (int i = 1; i <= x; i++)
        {
            res += (y + (i % 5)) / 5;
        }
        wln(res);
    }
    //////////////////////////////////////////////////

    static void swap(ref object o1, ref object o2) { var o = o1; o1 = o2; o2 = o; }
    static void wln(object o = null) { Console.WriteLine(o); }
    static void wsp(object o) { Console.Write(o + " "); }
    static void wrt(object o) { Console.Write(o); }
    //Console.Write(string.Format(CultureInfo.InvariantCulture, "{0:F12}", o));

    static long gcd(long a, long b) { return (b != 0) ? gcd(b, a % b) : a; }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }

    int ri
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            int p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    long rl
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind;
            int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0;
            while (_ind < _count && _str[_ind] != ' ') p = p * 10 + _str[_ind++] - '0';
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return p * sign;
        }
    }
    double rd
    {
        get
        {
            _read(); while (_str[_ind] == ' ') ++_ind; int sign = 1; if (_str[_ind] == '-') { sign = -1; ++_ind; }
            long p = 0, q = 1; while (_ind < _count && _str[_ind] != ' ' && _str[_ind] != '.') p = p * 10 + _str[_ind++] - '0';
            if (_ind < _count && _str[_ind] == '.') { ++_ind; while (_ind < _count && _str[_ind] != ' ') { p = p * 10 + _str[_ind++] - '0'; q *= 10; } }
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return (double)p / q * sign;
        }
    }
    string rs
    {
        get
        {
            _read(); while (_ind < _count && _str[_ind] == ' ') ++_ind;
            var tmp = _str.IndexOf(' ', _ind);
            if (tmp == -1) { _count = 0; _ind = 0; return _str.Substring(_ind); }
            var s = _str.Substring(_ind, tmp - _ind); _ind = tmp + 1;
            while (_ind < _count && _str[_ind] == ' ') ++_ind; return s;
        }
    }

    int[] ria(int n)
    {
        var res = new int[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                int p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    long[] rla(int n)
    {
        var res = new long[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0; while (i < m && s[i] != ' ') p = p * 10 + s[i++] - '0'; res[k++] = p * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    double[] rda(int n)
    {
        var res = new double[n];
        for (int k = 0; k < n;)
        {
            var s = Console.ReadLine(); var m = s.Length;
            for (int i = 0; i < m && k < n; ++i)
            {
                while (i < m && s[i] == ' ') ++i; if (i == m) break; int sign = 1; if (s[i] == '-') { sign = -1; ++i; }
                long p = 0, q = 1; while (i < m && s[i] != ' ' && s[i] != '.') p = p * 10 + s[i++] - '0';
                if (i < m && s[i] == '.') { ++i; while (i < m && s[i] != ' ') { p = p * 10 + s[i++] - '0'; q *= 10; } }
                res[k++] = (double)p / q * sign;
            }
        }
        _count = 0; _ind = 0; return res;
    }
    string[] rsa(int n) { var res = new string[n]; for (int k = 0; k < n; ++k) res[k] = Console.ReadLine(); _count = 0; _ind = 0; return res; }
    string _str = null; int _count = 0; int _ind = 0;
    void _read() { if (_ind == _count) { _str = Console.ReadLine(); _count = _str.Length; _ind = 0; } }
    static void Main() { new Program().Solution(); }
}


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

namespace CodeforcesRound358A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp = Console.ReadLine().Split();

            int n = Convert.ToInt32(inp[0]);
            int m = Convert.ToInt32(inp[1]);
            int k = 0;

            long cnt = 0;

            for (int i = 1; i <= n; i++)
            {
                k = (i/5 + 1) * 5 - i;

                cnt += m / 5;
                if (m % 5 >= k)
                    cnt++;
            }

            Console.WriteLine(cnt);
            //inp = Console.ReadLine().Split();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
public class Codeforces
{
    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
        reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
        var n = ReadInt();
        var b = ReadIntArray().OrderBy(d => d).ToArray();
        var c = 0;
        for (int i = 0; i < n; i++)
        {
            if (i + 1 > c * (b[i] + 1))
            {
                c++;
            }
        }
        writer.WriteLine(c);
        reader.Close();
        writer.Close();
    }
    #region Read / Write

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

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

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

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

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

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

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

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

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }
    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }
    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write<T>(params T[] array)
    {
        WriteArray(array);
    }

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


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

public class Program
{
    public static void Main(string[] args)
    {
        var n = Int32.Parse(Console.ReadLine());
        var X = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
        Array.Sort(X);
        n++;
        var list = new int[n];
        foreach (var x in X)
        {
            var y = x;
            for (int i = 0; i < n; i++)
            {
                if (list[i] <= y)
                {
                    list[i]++;
                    break;
                }
            }
        }
        for (int i = 0; i < n; i++)
            if (list[i] == 0)
            {
                Console.WriteLine(i);
                return;
            }

    }
}