#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
using namespace std;
int a[500][500],jl,n,m;
int main(){
freopen("djsa.in","r",stdin);
freopen("djsa.out","w",stdout);
cin>>n>>m;
for (int i=0;i<=n-1;++i)
for (int j=0;j<=n-1;++j)
a[i][j]=10000000;
for (int i=1;i<=m;++i)
{
int x,y,z;
cin>>x>>y>>z;
a[x][y]=a[y][x]=z;
}
for (int k=0;k<=n-1;++k)
for (int i=0;i<=n-1;++i)
if (i!=k)
for (int j=0;j<=n-1;++j)
if (i!=j)
if (a[i][k]+a[k][j]<a[i][j]) a[i][j]=a[i][k]+a[k][j];
int max=-1010;
int zmax=100000000;
for (int i=0;i<=n-1;++i)
{
max=-1000;
for (int j=0;j<=n-1;++j)
if (i!=j)
{
if (a[i][j]>max) max=a[i][j];
}
if (max<zmax)
{
jl=i;
zmax=max;
}
}
cout<<jl;
}