#include <bits/stdc++.h>
// #pragma optimize ("g",on)
// #pragma GCC optimize ("inline")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC optimize ("03")
// #pragma comment(linker, "/stack:200000000")
// #pragma warning(disable : 4996)
using namespace std;
const int N=1e5+5;
#define all(x) (x).begin(), (x).end()
#define bll(x) (x), (x)+n
#define forn(i, n) for(int i=0; i < (n); ++i)
#define forauto(i, n) for(int (i):(n));
#define scanfor(a, n) for(int i=0;i <(n); ++i)scanf("%lld",a+i)
#define int long long
#define pb push_back
#define NO {cout<<"NO\n";return;}
#define YES {cout<<"YES\n";return;}
#define sc(x) scanf("%lld",&x);
string a,b;
int n,m;
vector<vector<int>> g(N);
int cnt[N];
deque<int> d;
bool mark[N];
int mx=0;
void bfs(int st,int e){
// int p=0;
d.push_back(st);
while(d.size()){
int r=d.front();
d.pop_front();
mark[r]=1;
for(int i:g[r]){
if(!mark[i] && e!=i){
cnt[i]++;
mx=max(mx,cnt[i]);
d.push_back(i);
}
}
// 9 12
// 1 2
// 1 3
// 1 4
// 2 5
// 3 5
// 4 5
// 5 6
// 5 7
// 5 8
// 6 9
// 7 9
// 8 9
// 1 9
}
}
void Press_Shift_CMD_B(){
cin>>n>>m;
for(int i=0,x,y;i<m;i++){
cin>>x>>y;
g[x].push_back(y);
}
int x,y;
cin>>x>>y;
bfs(x,y);
for(int i=1;i<=n;i++){
mx=max(mx,cnt[i]);
}
int ans=0;
mark[x]=0;
mark[y]=0;
for(int i=1;i<=n;i++){
if(i==x || y==i)continue;
if(mark[i] &&mx==cnt[i]){
ans++;
mark[i]=0;
for(int j:g[i]){
mark[j]=0;
}
for(int j:g[i]){
for(int k:g[j]){
if(mark[i] && k!=x && k!=y){
mark[j]=1;
break;
}
}
}
}
//cout<<cnt[i]<<' ';
}
// cout<<'\n';
x=g[x].size()?g[x].size():INT_MAX;
y=g[y].size()?g[y].size():INT_MAX;
cout<<min({x,y,ans})<<endl;
}
signed main(){
int t=1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2lkIGJmcyhpbnQgc3QsaW50IGUpewogICAgLy8gaW50IHA9MDsKICAgIGQucHVzaF9iYWNrKHN0KTsKICAgIHdoaWxlKGQuc2l6ZSgpKXsKICAgICAgICBpbnQgcj1kLmZyb250KCk7CiAgICAgICAgZC5wb3BfZnJvbnQoKTsKICAgICAgICBtYXJrW3JdPTE7CiAgICAgICAgZm9yKGludCBpOmdbcl0pewogICAgICAgICAgICBpZighbWFya1tpXSAmJiBlIT1pKXsKICAgICAgICAgICAgICAgIGNudFtpXSsrOwogICAgICAgICAgICAgICAgbXg9bWF4KG14LGNudFtpXSk7CiAgICAgICAgICAgICAgICBkLnB1c2hfYmFjayhpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KLy8gOSAxMgovLyAxIDIKLy8gMSAzCi8vIDEgNAovLyAyIDUKLy8gMyA1Ci8vIDQgNQovLyA1IDYKLy8gNSA3Ci8vIDUgOAovLyA2IDkKLy8gNyA5Ci8vIDggOQovLyAxIDkKICAgIH0KfQp2b2lkIFByZXNzX1NoaWZ0X0NNRF9CKCl7CiAgICBjaW4+Pm4+Pm07CiAgICBmb3IoaW50IGk9MCx4LHk7aTxtO2krKyl7CiAgICAgICAgY2luPj54Pj55OwogICAgICAgIGdbeF0ucHVzaF9iYWNrKHkpOwogICAgfQogICAgaW50IHgseTsKICAgIGNpbj4+eD4+eTsKICAgIGJmcyh4LHkpOwogICAgZm9yKGludCBpPTE7aTw9bjtpKyspewogICAgICAgIG14PW1heChteCxjbnRbaV0pOwogICAgfQogICAgaW50IGFucz0wOwogICAgbWFya1t4XT0wOwogICAgbWFya1t5XT0wOwogICAgZm9yKGludCBpPTE7aTw9bjtpKyspewogICAgICAgIGlmKGk9PXggfHwgeT09aSljb250aW51ZTsKICAgICAgICBpZihtYXJrW2ldICYmbXg9PWNudFtpXSl7CiAgICAgICAgICAgIGFucysrOwogICAgICAgICAgICBtYXJrW2ldPTA7CiAgICAgICAgICAgIGZvcihpbnQgajpnW2ldKXsKICAgICAgICAgICAgICAgIG1hcmtbal09MDsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IoaW50IGo6Z1tpXSl7CiAgICAgICAgICAgICAgICBmb3IoaW50IGs6Z1tqXSl7CiAgICAgICAgICAgICAgICAgICAgaWYobWFya1tpXSAmJiBrIT14ICYmIGshPXkpewogICAgICAgICAgICAgICAgICAgICAgICBtYXJrW2pdPTE7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAvL2NvdXQ8PGNudFtpXTw8JyAnOwogICAgfQogICAgCiAgICAvLyBjb3V0PDwnXG4nOwogICAgeD1nW3hdLnNpemUoKT9nW3hdLnNpemUoKTpJTlRfTUFYOwogICAgeT1nW3ldLnNpemUoKT9nW3ldLnNpemUoKTpJTlRfTUFYOwogICAgY291dDw8bWluKHt4LHksYW5zfSk8PGVuZGw7Cn0KCnNpZ25lZCBtYWluKCl7CiAgICBpbnQgdD0xOwogICAgLy8gY2luPj50OwogICAgd2hpbGUodC0tKVByZXNzX1NoaWZ0X0NNRF9CKCk7CiAgICByZXR1cm4gMDsKfQ==