#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> g(n + 1);
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
  }
  long long reach[n + 1];
  long long sv[n + 1], rmv[n + 1];
  memset(reach, 0, sizeof(reach));
  memset(sv, 0, sizeof(sv));
  memset(rmv, 0, sizeof(rmv));
  for (long long i = 1; i <= n; i++) {
    if (rmv[i] == 0) {
      rmv[i] = 1;
      sv[i] = 1;
      for (auto it : g[i]) rmv[it] = 1;
    }
  }
  vector<long long> ans;
  for (long long i = n; i >= 1; i--) {
    if (sv[i] && reach[i] == 0) {
      ans.push_back(i);
      for (auto it : g[i]) reach[it] = 1;
    }
  }
  cout << ans.size() << "\n";
  for (auto it : ans) cout << it << " ";
  return 0;
}
