#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 16;
vector<int> g[N], rg[N];
int vis[N], taken[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    rg[v].push_back(u);
  }
  vector<int> vec;
  memset(vis, false, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    vec.push_back(i);
    for (int u : g[i]) {
      vis[u] = true;
    }
    taken[i] = true;
  }
  vector<int> ans;
  while (!vec.empty()) {
    int v = vec.back();
    bool flg = true;
    for (int u : rg[v]) {
      if (taken[u]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      ans.push_back(v);
    } else {
      taken[v] = false;
    }
    vec.pop_back();
  }
  cout << ans.size() << '\n';
  for (int x : ans) {
    cout << x << " ";
  }
  cout << '\n';
  return 0;
}
