#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	int y1, y2, m, d, x1, x2, u = 1;
	
	cin >> y1 >> m >> d;
	x1 = m * 100 + d;
	cin >> y2 >> m >> d;
	x2 = m * 100 + d;

	if ((y1 - y2)*(x1 - x2) < 0 || x1 == x2)
		u = 0;

	cout << abs(y1 - y2) + u << endl;

	return 0;
}

