#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <class K, class V>
class RadixHeap {
    static constexpr int bit_length = sizeof(K)*8;
    K last;
    size_t sz, cnt;

    array<vector<pair<K, V>>, bit_length> v;
    static inline int bsr(int x){
        return x ? bit_length-__builtin_clz(x) : 0;
    }
    static inline int bsr(ll x){
        return x ? bit_length-__builtin_clzll(x) : 0;
    }

    void pull() {
        if(cnt < v[0].size()) return;;
        int i = 1;
        while(v[i].empty()) i++;
        last = min_element(v[i].begin(),v[i].end())->first;
        for (auto &&x : v[i]) v[bsr(x.first ^ last)].push_back(x);
        v[i].clear();
    }
public:
    RadixHeap() : last(0), sz(0), cnt(0) {}
    void emplace(K x, V val){
        sz++;
        v[bsr(x^last)].emplace_back(x, val);
    }

    pair<K, V> top() {
        pull();
        return v[0][cnt];
    }

    void pop() {
        pull();
        sz--;
        cnt++;
    }

    size_t size() const { return sz; }
    bool empty() const { return !sz; }
};

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge<int>>> G(n);
    for (int i = 0; i < m; ++i) {
        int s, t, d;
        scanf("%d %d %d", &s, &t, &d);
        s--; t--;
        G[s].emplace_back(t, d);
        G[t].emplace_back(s, d);
    }
    RadixHeap<int, int> Q;
    auto d = make_v(n, n, INF<int>);
    vector<int> ok(n, 1);
    for (int s = 0; s < n; ++s) {
        d[s][s] = 0;
        Q.emplace(0, s);
        while(!Q.empty()){
            int cost; int i;
            tie(cost, i) = Q.top(); Q.pop();
            if(d[s][i] < cost) continue;
            for (auto &&e : G[i]) {
                auto cost2 = cost + e.cost;
                if(d[s][e.to] <= cost2) continue;
                d[s][e.to] = cost2;
                Q.emplace(d[s][e.to], e.to);
            }
        }
    }
    int val = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            chmax(val, d[i][j]);
        }
    }
    for (int i = 0; i < n; ++i) {
        queue<int> q;
        vector<int> visited(n);
        for (int j = 0; j < n; ++j) {
            if(d[i][j] == val){
                q.emplace(j);
                visited[j] = 1;
            }
        }
        while(!q.empty()){
            int x = q.front(); q.pop();
            ok[x] = 0;
            for (auto &&y : G[x]) {
                if(!visited[y.to] && d[i][y.to]+y.cost == d[i][x]){
                    q.emplace(y.to);
                    visited[y.to] = 1;
                }
            }
        }
    }
    cout << accumulate(ok.begin(),ok.end(), 0) << "\n";
    for (int i = 0; i < n; ++i) {
        if(ok[i]) cout << i+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 45024