
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

pair<int, pair<int, int>>p1, p2;

int main(void)
{
	cin >> p1.first >> p1.second.first >> p1.second.second;
	cin >> p2.first >> p2.second.first >> p2.second.second;
	if (p1 > p2)swap(p1, p2);
	if (p1.second < p2.second) {
		cout << p2.first - p1.first + 1 << endl;
	}
	else {
		cout << p2.first - p1.first << endl;
	}
	return 0;
}

