include[HTML_REMOVED]
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=100010;
struct qnode
{
int v;
int c;
qnode(int _v=0,int _c=0):v(_v),c(_c){}
bool operator <(const qnode &r)const
{
return c>r.c;
}
};
struct Edge
{
int v,cost;
Edge(int _v=0,int _cost=0):v(_v),cost(_cost){}
};
vector[HTML_REMOVED] E[MAXN];
bool vis[MAXN];
int dist[MAXN];
void dijk(int n,int start)
{
memset(vis,false,sizeof(vis));
for(int i=1;i<=n;i) dist[i]=INF;
priority_queue[HTML_REMOVED] que;
while(!que.empty()) que.pop();
dist[start]=0;
que.push(qnode(start,0));
qnode tmp;
while(!que.empty())
{
tmp=que.top();
que.pop();
int u=tmp.v;
if(vis[u]) continue;
vis[u]=true;
for(int i=0;i[HTML_REMOVED]dist[u]+cost)
{
dist[v]=dist[u]+cost;
que.push(qnode(v,dist[v]));
}
}
}
}
void addedge(int u,int v,int w)
{
E[u].push_back(Edge(v,w));
E[v].push_back(Edge(u,w));
}
int main()
{
for(int i=0;i<=MAXN;i)
if(!E[i].empty())
E[i].clear();
int n,p,c,m;
cin>>n>>p>>c;
cin>>m;
int u,v,w=1;
for(int i=1;i<=p;i)
{
cin>>u>>v;
addedge(u,v,w);
}
dijk(n,c);
int maxl=0;
for(int i=1;i<=n;i)
if(vis[i]) maxl=max(maxl,dist[i]);
cout<<maxl+m+1;
return 0;
}