#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000009;
int firs[maxn], x, y, n, m, h, cnt, cs[maxn], re[maxn];
struct edge {
  int too, nex;
} g[maxn];
int read() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x;
}
void write(int x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void add(int x, int y) {
  g[++h].too = y;
  g[h].nex = firs[x];
  firs[x] = h;
}
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; ++i) {
    x = read(), y = read();
    add(x, y);
  }
  for (register int i = 1; i <= n; ++i)
    if (!re[i]) {
      re[i] = i;
      for (register int j = firs[i]; j; j = g[j].nex)
        if (!re[g[j].too]) re[g[j].too] = i;
      cs[i] = true;
    }
  for (register int i = n; i >= 1; --i)
    if (re[i] == i)
      if (cs[i]) {
        for (register int j = firs[i]; j; j = g[j].nex) cs[g[j].too] = false;
      }
  for (register int i = 1; i <= n; ++i)
    if (cs[i]) cnt++;
  printf("%d\n", cnt);
  for (register int i = 1; i <= n; ++i)
    if (cs[i]) {
      write(i);
      putchar(' ');
    }
  return 0;
}
