#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
vector<int> to[maxn], pre[maxn];
int n, m, vis[maxn], p;
void solve() {
  while (p <= n && vis[p] != 0) p++;
  if (p > n) return;
  int u = p;
  vis[u] = 1;
  for (int v : to[u])
    if (vis[v] == 0) vis[v] = -1;
  solve();
  for (int pp : pre[u])
    if (vis[pp] == 1) vis[u] = 0;
}
vector<int> ans;
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    to[u].push_back(v);
    pre[v].push_back(u);
  }
  p = 1;
  solve();
  for (int i = 1; i <= n; i++)
    if (vis[i] == 1) {
      ans.push_back(i);
    }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); i++) {
    printf("%d%c", ans[i], " \n"[i == (int)ans.size() - 1]);
  }
  return 0;
}
