#include <bits/stdc++.h>
using namespace std;
set<int> s;
int n, m, q[1000005], cho[1000005], t[1000005];
vector<int> e[1000005], ee[1000005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    ee[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) s.insert(i), t[i] = 1;
  int tot = 0;
  for (; s.size();) {
    int x = q[++tot] = *s.begin();
    s.erase(x);
    t[x] = 0;
    for (auto y : e[x])
      if (t[y]) s.erase(y), t[y] = 0;
  }
  for (; tot; tot--) {
    int x = q[tot], have = 0;
    for (auto y : ee[x]) have |= cho[y];
    cho[x] = have ^ 1;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) cnt += cho[i];
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (cho[i]) printf("%d ", i);
  puts("");
}
