#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[102][102];
int main()
{
#ifndef COGS
freopen("djsa.in","r",stdin);
freopen("djsa.out","w",stdout);
#endif // COGS
memset(a,0x3f,sizeof(a));
int m,n,ans=2147483647,pos;
scanf("%d%d",&n,&m);
for (int i=1;i<=m;++i)
{
int s,e,dis;
scanf("%d%d%d",&s,&e,&dis);
a[s][e]=a[e][s]=dis;
}
for (int k=0;k<n;++k)
for (int i=0;i<n;++i)
for (int j=0;j<n;++j)
{
if (i!=j && a[i][j]>a[i][k]+a[k][j]) a[i][j]=a[i][k]+a[k][j];
}
for (int i=0;i!=n;++i)
{
int l=0;
for (int j=0;j!=n;++j)
if (a[i][j]>l && a[i][j]!=1061109567) {l=a[i][101]=a[i][j];}
}
for (int i=n-1;~i;--i)
{
if(a[i][101]<=ans) {ans=a[i][101];pos=i;}
}
printf("%d\n",pos);
return 0;
}