#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, M = N << 1;
template <typename T>
inline void read(T& x) {
  x = 0;
  char q;
  short f = 1;
  while (!isdigit(q = getchar()))
    if (q == '-') f = -1;
  while (isdigit(q)) {
    x = (x << 1) + (x << 3) + (q ^ 48);
    q = getchar();
  }
  x *= f;
}
template <typename T>
inline void print(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int ne[M], h[N], to[M], cnt, n, m, vis[N], sel[N];
void add(int a, int b) {
  ne[++cnt] = h[a];
  to[cnt] = b;
  h[a] = cnt;
}
int tmp, q[N];
int main() {
  read(n);
  read(m);
  while (m--) {
    int a, b;
    read(a);
    read(b);
    add(a, b);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      sel[i] = 1;
      vis[i] = 1;
      for (int j = h[i]; j; j = ne[j]) vis[to[j]] = 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (sel[i]) {
      for (int j = h[i]; j; j = ne[j]) sel[to[j]] = 0;
    }
  }
  int now = 0;
  for (int i = 1; i <= n; i++)
    if (sel[i]) q[++now] = i;
  print(now);
  puts("");
  for (int i = 1; i <= now; i++) print(q[i]), printf(" ");
  return 0;
}
