#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1e9;
const int MAX_N = 1500 + 9;
vector<pair<int, int> > g[MAX_N], Path;
int n, m, maxDist;
int dist[MAX_N][MAX_N];
bool used[MAX_N];

void read(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        g[u].push_back(make_pair(v, w));
        g[v].push_back(make_pair(u, w));
    }
}

void dijk(int s){
    for(int i = 1; i <= n; i++)
        dist[s][i] = INF;

    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > pq;
    dist[s][s] = 0; pq.push(make_pair(dist[s][s], s));
    while(!pq.empty()){
        int du = pq.top().first, u = pq.top().second; pq.pop();

        if(du != dist[s][u])
            continue;

        for(int i = 0, L = g[u].size(); i < L; i++){
            int v = g[u][i].first;
            int w = g[u][i].second;
            if(dist[s][v] > dist[s][u] + w){
                dist[s][v] = dist[s][u] + w;
                pq.push(make_pair(dist[s][v], v));
            }
        }
    }
}

void solve(){
    for(int i = 1; i <= n; i++)
        dijk(i);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            maxDist = max(maxDist, dist[i][j]);

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            if(dist[i][j] == maxDist)
                Path.push_back(make_pair(i, j));

    for(int i = 1; i <= n; i++)
        if(!used[i]){
            for(int j = 0, L = Path.size(); j < L; j++){
                int u = Path[j].first, v = Path[j].second;
                if(dist[u][i] + dist[i][v] == dist[u][v]){
                    used[i] = true;
                    break;
                }
            }
        }

    int res = 0;
    for(int i = 1; i <= n; i++)
        if(!used[i])    res++;

    cout << res << '\n';
    for(int i = 1; i <= n; i++)
        if(!used[i])    cout << i << '\n';
}

int main()
{
    read();
    solve();
    return 0;
}

