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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var linija = Console.ReadLine().Split();
            int x1 = int.Parse(linija[0]);
            int y1 = int.Parse(linija[1]);
            var linija1 = Console.ReadLine().Split();
            int x2 = int.Parse(linija1[0]);
            int y2 = int.Parse(linija1[1]);
            if (x1 == x2 || y1 == y2)
                Console.WriteLine("2");
            else if (x1 == y1 && x2 == y2)
                Console.WriteLine("1");
            else
                Console.WriteLine("0");
            
        }
    }
}