#include <bits/stdc++.h>
#define up(i, a, b) for (int i = a, _b = b; i <= _b; i++)
#define down(i, a, b) for (int i = a, _b = b; i >= _b; i--)
#define long long long
#define endl '\n'
#define w first
#define v second
#define II pair<int, int>
#define debug(X) cerr << #X << " = " << X << endl
#define debug2(X, Y) cerr << #X << " = " << X << " , " << #Y << " = " << Y << endl
#define show(X, a, b) { cerr << #X << " = "; up(_, a, b) cerr << X[_] << " "; cerr << endl; }
#define gc getchar
#define pc putchar
using namespace std;
inline void read(int &x) {
        register int c = gc();
        x = 0;
        int neg = 0;
        for (; ((c<48 || c>57) && c != '-'); c = gc());
        if(c=='-') {neg=1; c=gc();}
        for(; c>47 && c<58; c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
        if(neg) x=-x;
}
inline void writeln(int x) {

        char buffor[21];
        register int i=0;
        int neg=0; if (x<0) {neg=1; x= -x;}
        do {
                buffor[i++]=(x%10)+'0';
                x/=10;
        } while(x);
        i--;
        if (neg) pc('-');
        while(i>=0) pc(buffor[i--]);
        pc('\n');
}
const int N = 1510;
const int oo = 1e9;
int d[N], rev_d[N], n, m;
vector<II> a[N];
bool useful[N];
vector<int> candidate[N];
int max_from[N];
void input() {
        cin >> n >> m;
        up(i, 1, m) {
            int u, v, w; cin >> u >> v >> w;
            a[u].push_back(II(w, v));
            a[v].push_back(II(w, u));
        }
}
void dijikstra(int s) {
        up(i, 1, n) d[i] = oo;
        d[s] = 0;
        priority_queue<II, vector<II>, greater<II> > pq;
        pq.push(II(d[s], s));
        while (!pq.empty()) {
            int du = pq.top().w, u = pq.top().v; pq.pop();
            if (du != d[u]) continue;
            for (auto e: a[u])
              if (d[e.v] > d[u] + e.w) {
                d[e.v] = d[u] + e.w; pq.push(II(d[e.v], e.v));
              }
        }

        int maxd = 0;
        up(i, 1, n)
          if (d[i] > maxd) maxd = d[i];
        max_from[s] = maxd;

        //from now we use rev_d
        up(i, 1, n) rev_d[i] = oo;
        up(i, 1, n)
          if (d[i] == maxd) rev_d[i] = 0, pq.push(II(rev_d[i], i));
        while (!pq.empty()) {
            int rev_du = pq.top().w, u = pq.top().v; pq.pop();
            if (rev_du != rev_d[u]) continue;
            for (auto e: a[u])
              if (rev_d[e.v] > rev_d[u] + e.w) {
                 rev_d[e.v] = rev_d[u] + e.w; pq.push(II(rev_d[e.v], e.v));
              }
        }

        up(i, 1, n)
          if (d[i] + rev_d[i] == maxd) candidate[s].push_back(i);
}
void solve() {
        up(i, 1, n) dijikstra(i);
        int max_all = 0;
        up(i, 1, n) max_all = max(max_all, max_from[i]);
        up(i, 1, n)
          if (max_from[i] == max_all)
            for (auto v: candidate[i]) useful[v] = 1;
        int res = 0;
        up(i, 1, n)
          if (!useful[i]) res++;
        cout << res << endl;
        up(i, 1, n)
          if (!useful[i]) cout << i << endl;
}
int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

  #ifdef I_Love_Pork
  #define TASK "tmp"
        freopen(TASK ".inp","r",stdin);
        freopen(TASK ".out","w",stdout);
  #endif


        input();
        solve();



        return 0;
}



Measured memory_bytes: 15196