#include <bits/stdc++.h>
using namespace std;
vector<int> adj1[1000050], adj2[1000050];
bool vis1[1000050], vis2[1000050];
vector<int> ans;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj1[u].push_back(v);
    adj2[v].push_back(u);
  }
  for (int i = n; i >= 0; i--) {
    if (!vis1[i]) {
      vis1[i] = true;
      vis2[i] = true;
      for (auto c : adj1[i]) vis1[c] = true;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis2[i]) {
      for (auto c : adj2[i]) {
        if (vis2[c]) vis2[i] = false;
      }
      if (vis2[i]) ans.push_back(i);
    }
  }
  printf("%d\n", ans.size());
  for (auto c : ans) printf("%d ", c);
  return 0;
}
