#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#define MAXN 100000000
using namespace std;
int a[500][500],pos,n,m;
inline int Main(){
freopen("djsa.in","r",stdin);
freopen("djsa.out","w",stdout);
cin>>n>>m;
for (int i=0;i<n;i++)
for (int j=0;j<n;j++)
a[i][j]=MAXN;
for (int i=0;i<m;i++)
{
int x,y,z;
cin>>x>>y>>z;
a[x][y]=a[y][x]=z;
}
for (int k=0;k<n;k++)
for (int i=0;i<n;i++)
if (i!=k)
for (int j=0;j<n;j++)
if (i!=j)
if (a[i][k]+a[k][j]<a[i][j]) a[i][j]=a[i][k]+a[k][j];
int maxx=MAXN;int max;
for (int i=0;i<n;i++)
{
max=-MAXN;
for (int j=0;j<n;j++)
if (i!=j)
{
if (a[i][j]>max) max=a[i][j];
}
if (max<maxx)
{
pos=i;
maxx=max;
}
}
cout<<pos;
fclose(stdin);
fclose(stdout);
return 0;
}
int work=Main();
int main(){;}