#include <bits/stdc++.h>
using namespace std;
const int NN = 1000007;
vector<int> adj[NN];
int vst[NN], ans[NN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; i++)
    if (!vst[i]) {
      vst[i] = 1;
      for (int v : adj[i])
        if (!vst[v]) vst[v] = 2;
    }
  int cnt = 0;
  for (int i = n; i; i--)
    if (vst[i] == 1) {
      ans[++cnt] = i;
      for (int v : adj[i]) vst[v] = 2;
    }
  cout << cnt << endl;
  for (int i = 1; i <= cnt; i++) printf("%d ", ans[i]);
  return 0;
}
