#include <bits/stdc++.h>
#define FOR(i, a, b)    for (int i = a; i <= (int) b; ++i)
#define ii              pair <int, int>
using namespace std;
const int N = 1503;
int n, m;
vector <ii> adj[N];

void init() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);
}

priority_queue <ii, vector <ii>, greater <ii> > Q;
int d[N][N], Max;
void dijk(int st) {
    d[st][st] = 0; Q.push({ 0, st });
    while (Q.size()) {
        int u = Q.top().second, du = Q.top().first;
        Q.pop();
        if (du != d[st][u]) continue;
        Max = max(Max, du);
        for (ii it : adj[u]) {
            int v = it.second, w = it.first;
            if (d[st][v] > du + w) d[st][v] = du + w, Q.push({ d[st][v], v });
        }
    }
}

queue <int> dm;
int vis[N];
void trace(int st) {
    FOR(i, 1, n) if (d[st][i] == Max) dm.push(i), vis[i] = st;
    while (dm.size()) {
        int u = dm.front(); dm.pop();
        for (ii it : adj[u]) {
            int v = it.second, w = it.first;
            if (d[st][u] == d[st][v] + w && vis[v] < st) vis[v] = st, dm.push(v);
        }
    }
}

void solve() {
    cin >> n >> m;
    FOR(i, 1, m) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({ w, v }), adj[v].push_back({ w, u });
    }

    memset(d, 0x3f, sizeof d);
    FOR(i, 1, n) dijk(i);

    FOR(i, 1, n) trace(i);
    int dem = 0;
    FOR(i, 1, n) if (vis[i] == 0) ++dem;
    cout << dem << '\n';
    FOR(i, 1, n) if (vis[i] == 0) cout << i << '\n';
}

int main() {
    init(); solve();
}

