#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000000 + 342];
set<int> ans;
bool incl[1000000 + 342];
bool isleader[1000000 + 342];
map<pair<int, int>, bool> egd;
int main() {
  ios::sync_with_stdio(false);
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    if (egd[make_pair(x, y)] == false) {
      adj[x].push_back(y);
      egd[make_pair(x, y)] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (incl[i] == false) {
      for (auto next : adj[i]) {
        if (next > i)
          if (incl[next] == false) {
            incl[next] = true;
          }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (incl[i] == false) {
      ans.insert(i);
      for (auto next : adj[i]) {
        incl[next] = true;
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto bc : ans) cout << bc << " ";
  return 0;
}
