#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
struct node {
  int to, nxt;
} edge[N << 1];
int n, m, num, head[N], cnt;
bool vis[N], use[N];
inline int read() {
  int x = 0, w = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * w;
}
inline void add_edge(int from, int to) {
  edge[++num] = (node){to, head[from]};
  head[from] = num;
}
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= m; i++) {
    int x = read(), y = read();
    add_edge(x, y);
  }
  for (register int k = 1; k <= n; k++) {
    if (use[k]) continue;
    vis[k] = 1;
    for (register int i = head[k]; i; i = edge[i].nxt) use[edge[i].to] = 1;
  }
  for (register int k = n; k >= 1; k--) {
    if (!vis[k]) continue;
    for (register int i = head[k]; i; i = edge[i].nxt) vis[edge[i].to] = 0;
  }
  for (register int i = 1; i <= n; i++)
    if (vis[i]) ++cnt;
  printf("%d\n", cnt);
  for (register int i = 1; i <= n; i++)
    if (vis[i]) printf("%d ", i);
  return 0;
}
