#include <iostream>
using namespace std;

int main()
{
	int vertSize;
	int horSize;
	int firstNumber;
	int lastNumber;
	cin >> horSize >> vertSize >> firstNumber >> lastNumber;
	//создание динамического массива
	int*** arr;
	arr = new int**[vertSize];
	int count = 1;
	int z = 2;
	int apos[3];
	int bpos[3];
	for (int i = 0; i < vertSize; i++)
	{
		arr[i] = new int*[horSize];
		for (int j = 0; j < horSize; j++)
		{
			arr[i][j] = new int[z];
			for (int k = 0; k < 2; k++)
			{
				arr[i][j][k] = count;
				count++;
				// определяем позицию наших элементов в массиве
				if (arr[i][j][k] == firstNumber)
				{
					apos[0] = i;
					apos[1] = j;
					apos[2] = k;
				}
				if (arr[i][j][k] == lastNumber)
				{
					bpos[0] = i;
					bpos[1] = j;
					bpos[2] = k;
				}
			}
		}
	}
	int hor;
	int vert;
	// направление движения по вертикали
	vert = apos[0] < bpos[0] ? 1 : (apos[0] == bpos[0] ? 0 : -1);
	// направление движения по горизонтали
	hor = apos[1] < bpos[1] ? 1 : (apos[1] == bpos[1] ? 0 : -1);
	int stepCount = 0;
	int curCell[3];
	for (int i = 0; i < 3; i++)
		curCell[i] = apos[i];

	bool dir;
	if (apos[1] < bpos[1] && firstNumber % 2 == 0 || apos[1] > bpos[1] && firstNumber % 2 != 0)
		dir = false;
	else
		dir = true;
	while (1)
	{
		if (dir && vert != 0)
		{
			if (vert == -1)
			{
				if (curCell[2] == 0)
					curCell[0]--;
				curCell[2] = !((bool)curCell[2]);
				stepCount++;
			}
			else
			{
				if (curCell[2] == 1)
					curCell[0]++;
				curCell[2] = !((bool)curCell[2]);
				stepCount++;
			}
		}
		else if (!dir && hor != 0)
		{
			if (hor == -1)
			{
				if (curCell[2] == 0)
					curCell[1]--;
				curCell[2] = !((bool)curCell[2]);
				stepCount++;
			}
			else
			{
				if (curCell[2] == 1)
					curCell[1]++;
				curCell[2] = !((bool)curCell[2]);
				stepCount++;
			}
		}
		dir = !dir;

		if (curCell[0] == bpos[0])
			vert = 0;
		if (curCell[1] == bpos[1])
			hor = 0;

		if (curCell[0] == bpos[0] && curCell[1] == bpos[1] && curCell[2] != bpos[2])
		{
			curCell[2] = !((bool)curCell[2]);
			stepCount++;
		}

		bool end;
		for (int i = 0; i < 3; i++)
		{
			if (curCell[i] != bpos[i])
			{
				end = false;
				break;
			}
			end = true;
		}
		if (end)
			break;
	}
	cout << stepCount << endl;
	return 0;
}