#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define S second
#define F first

using namespace std;

int main(void){
    pair<int, pair<int, int> > y1, y2;
  cin >> y1.F >> y1.S.F >> y1.S.S;
  cin >> y2.F >> y2.S.F >> y2.S.S;

  if ( y1 > y2 ) swap(y1, y2);
  int pp=0;
  if(y1.S<y2.S)pp=1;
  cout <<  y2.F - y1.F + pp<< endl;
}
