using System;
using System.Runtime.CompilerServices;
using System.Security.Principal;

namespace takmicenje1
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string[] pt = Console.ReadLine().Split();
            string[] dt = Console.ReadLine().Split();

            if (Math.Abs(int.Parse(pt[0])) == Math.Abs(int.Parse(pt[1])) &&
                Math.Abs(int.Parse(dt[0])) == Math.Abs(int.Parse(dt[1])))
                Console.WriteLine("1");
            else if (Math.Abs(int.Parse(pt[0])) == Math.Abs(int.Parse(dt[0])) ||
                 Math.Abs(int.Parse(pt[1])) == Math.Abs(int.Parse(dt[1])))
                Console.WriteLine("2");
            else Console.WriteLine("0");
        }
    }
}