// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

ll rec[1600][1600];
struct Elem {
    ll pos, cost;
    Elem() {}
    Elem(ll a, ll b) : pos(a), cost(b) {}
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};
 
int main() {
    int N, R; cin >> N >> R;
    vector< vector< pair<int, int> > > G(N);
    for(int i=0; i<R; i++) {
        int u, v, d; cin >> u >> v >> d;
        u--; v--;
        G[u].emplace_back(v, d);
        G[v].emplace_back(u, d);
    }

    fill(rec[0], rec[N], INF);
    for(int s=0; s<N; s++) {
        priority_queue<Elem> que;
        que.emplace(s, 0);
        rec[s][s] = 0;
        while(que.size()) {
            Elem cur = que.top(); que.pop();
            if(cur.cost > rec[s][cur.pos]) continue;
            for(auto e : G[cur.pos]) {
                int u = cur.pos, v = e.first, c = e.second;
                if(rec[s][v] > cur.cost + c) {
                    rec[s][v] = cur.cost + c;
                    que.emplace(v, rec[s][v]);
                }
            }
        }
    }

    ll max_cost = -1;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            max_cost = max(max_cost, rec[i][j]);
        }
    }

    vector< pair<int, int> > pairs;
    for(int i=0; i<N; i++) {
        for(int j=i+1; j<N; j++) {
            if(rec[i][j] != max_cost) continue;
            pairs.emplace_back(i, j);
        }
    }

    // fprintf(stderr, "pairs size = %zu\n", pairs.size());
    vector<int> used(N);
    for(int i=0; i<N; i++) {
        for(auto st : pairs) {
            int s, t; tie(s, t) = st;
            if(rec[s][i] + rec[i][t] == max_cost) {
                used[i] = true;
                break;
            }
        }
    }

    vector<int> ans;
    for(int i=0; i<N; i++) if(!used[i]) ans.emplace_back(i);
    cout << ans.size() << endl;
    for(auto e : ans) cout << e+1 << endl;
    return 0;
}

