#include<iostream>
#include<vector>
using namespace std;
int n,m;
int father[101];
int find(int u){
if(u == father[u]) return u;
u = father[u];
u = find(u);
return u;
}
void join(int x,int y){
x = find(x);
y = find(y);
if(x == y) return;
father[y] = x;
}
bool isSame(int x,int y){
x = find(x);
y = find(y);
if(x == y) return true;
return false;
}
int main(){
cin >> n >> m;
for(int i = 1; i < 101; i++) {
father[i] = i;
}
int x,y;
while(m--){
cin >> x >> y;
join(x,y);
}
cin >> x >> y;
if(isSame(x,y)) cout << 1;
else cout << 0;
return 0;
}