#include<bits/stdc++.h>usingnamespace std;typedeflonglong ll;typedef pair<int,int>PII;constint N=2e5+10;constint MOD =998244353;constint INF=0X3F3F3F3F;constint dx[]={-1,1,0,0,-1,-1,+1,+1};constint dy[]={0,0,-1,1,-1,+1,-1,+1};constint M =1e6+10;//好累啊//spfa算法求最短路时间复杂度最坏n * mint n, m, s, t;
vector<PII>ed[N];int dis[N];
queue<int>q;bool st[N];voidspfa(){memset(dis,0x3f,sizeof dis);for(int i =1; i <= m; i ++){int u, v, w;
cin >> u >> v >> w;
ed[u].push_back({v, w});
ed[v].push_back({u, w});//因为是无向图}
dis[s]=0;
st[s]=true;
q.push(s);while(!q.empty()){int x = q.front();
q.pop();
st[x]=false;for(auto it : ed[x]){if(dis[it.first]<= dis[x]+ it.second)continue;
dis[it.first]= dis[x]+ it.second;if(!st[it.first]){
st[it.first]=true;
q.push(it.first);}}}}intmain(){
cin >> n >> m >> s >> t;//起点跟终点spfa();
cout << dis[t]<< endl;return0;}