#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 120;
int n, m;
int mat[MAXN][MAXN];
const int INF = 88888888;
void floyd()
{
for (int k = 0; k < n; k++)
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
mat[i][j] = min(mat[i][j], mat[i][k]+mat[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)
mat[i][j] = (i == j ? 0 : INF);
while (m--) {
scanf("%d%d%d", &u, &v, &w);
// if (w < mat[v][u])
mat[v][u] = mat[u][v] = w;
}
floyd();
int ans = -1;
int mins = INF;
for (int i = 0; i < n; ++i) {
int maxs = -1;
for (int j = 0; j < n; ++j) {
if (j == i)
continue;
if (mat[i][j] > maxs)
maxs = mat[i][j];
}
if (maxs < mins) {
mins = maxs;
ans = i;
}
}
printf("%d\n", ans);
return 0;
}