#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 110;
int n, m;
int lm[MAXN][MAXN];
const int INF =12345678;
void floyd()
{
for (int k = 0; k < n; k++)
for (int i=0;i<n; ++i)
for (int j=0;j<n;++j)
lm[i][j]=min(lm[i][j],lm[i][k]+lm[k][j]);
}
int main()
{
freopen("djsa.in","r",stdin);
freopen("djsa.out","w",stdout);
int u,v,w;
scanf("%d%d",&n,&m);
for(int i=0;i<n;++i)
for(int j=0;j<n;++j)
lm[i][j]=(i==j?0:INF);
while(m--){
scanf("%d%d%d",&u,&v,&w);
lm[v][u]=lm[u][v]=w;
}
floyd();
int ans=-1;
int lyj=INF;
for (int i=0;i<n;++i) {
int pml = -1;
for (int j=0;j<n;++j) {
if (j==i)
continue;
if (lm[i][j]>pml)
pml=lm[i][j];
}
if(pml<lyj) {
lyj=pml;
ans = i;
}
}
printf("%d\n",ans);
return 0;
}