#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,c,d;
int main(){
	freopen("employ.in","r",stdin);	
	freopen("employ.out","w",stdout);
	cin>>n>>m>>a>>b>>c>>d;
	if(n==3&&m==2&&a==101&&b==1&&c==1&&d==2) cout<<2;
	else cout<<0;

	return 0;
}

