#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
using AnsType = long long int;
using namespace std;

vector< pair<int, int> > G[1510];
AnsType rec[1510][1510];
const AnsType INF = 1LL << 60;
using Pair = pair<int, AnsType>;
int main() {
  int N, R; cin >> N >> R;
  for(int i=0; i<R; i++) {
    int s, t, d; cin >> s >> t >> d;
    s--; t--;
    G[s].emplace_back(t, d);
    G[t].emplace_back(s, d);
  }

  fill(rec[0], rec[N+1], INF);
  for(int s=0; s<N; s++) {
    priority_queue< Pair, vector<Pair>, greater<Pair> > que;
    que.emplace(s, 0);
    rec[s][s] = 0;

    while(que.size()) {
      int cur; AnsType cost; tie(cur, cost) = que.top(); que.pop();
      if(cost > rec[s][cur]) continue;
      for(auto e : G[cur]) {
        int to, c; tie(to, c) = e;
        if(rec[s][to] > cost + c) {
          rec[s][to] = cost + c;
          que.emplace(to, cost + c);
        }
      }
    }
  }

  vector<int> used(N);
  AnsType max_dist = -1;
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      max_dist = max(max_dist, rec[i][j]);
    }
  }

  vector< pair<int, int> > pairs;
  for(int i=0; i<N; i++) {
    for(int j=0; j<N; j++) {
      if(rec[i][j] == max_dist) {
        pairs.emplace_back(i, j);
      }
    }
  }
    
  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_dist) {
        used[i] = true;
        break;
      }
    }
  }

  vector<int> ans;
  for(int i=0; i<N; i++) {
    if(!used[i]) ans.push_back(i+1);
  }

  cout << ans.size() << endl;
  for(auto e : ans) cout << e << endl;
  return 0;
}

