program ping;
var
i,j,k,l:longint;
a:array[0..999,0..999]of longint;
f:array[1..100000]of longint;
p:array[0..999]of longint;
n,m,t:longint;
begin
assign(input,'ping.in');
reset(input);
assign(output,'ping.out');
rewrite(output);
readln(n,m,t);
for i:=0 to n-1 do
for j:=0 to n-1 do
a[i,j]:=-1;
for i:=1 to m do
begin
readln(j,k,l);
a[j,k]:=l;
a[k,j]:=l;
end;
p[0]:=0;
for i:=1 to n-1 do
p[i]:=maxlongint;
f[1]:=0;
i:=1;
j:=1;
while i<=j do
begin
for k:=0 to n-1 do
if a[f[i],k]<>-1 then
begin
if p[f[i]]+a[f[i],k]<p[k] then
begin
inc(j);
f[j]:=k;
p[k]:=a[f[i],k]+p[f[i]];
end;
end;
inc(i);
end;
if p[t]<>maxlongint then
writeln(p[t])
else
writeln('no');
close(input);
close(output);
end.