#include<bits/stdc++.h>

using namespace std;

int main () 
{
	int n ;
	cin>>n;
	
	int t = 0; 
	
	int r1 = 0;
	int k1 = 0;
	
	int r2 = 0;
	int k2 = 0;
	
	cin>>r1>>k1>>r2>>k2;
	
	if(k1 == k2) t++;
	if(r1 == r2) t++;
	
	cout<< t;
	return 0;
}