#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(int x) {
  write(x);
  puts("");
}
const int N = 1e6 + 5;
struct edge {
  int link, next;
} e[N];
int n, m, head[N], tot;
inline void add_edge(int u, int v) {
  e[++tot] = (edge){v, head[u]};
  head[u] = tot;
}
inline void init() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    add_edge(u, v);
  }
}
int ans;
bool vis[N], cho[N];
inline void solve() {
  for (int u = 1; u <= n; u++) {
    if (!vis[u]) {
      for (int i = head[u]; i; i = e[i].next) {
        int v = e[i].link;
        vis[v] = 1;
      }
      vis[u] = 1;
      cho[u] = 1;
    }
  }
  for (int u = n; u; u--) {
    if (cho[u]) {
      for (int i = head[u]; i; i = e[i].next) {
        int v = e[i].link;
        cho[v] = 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) ans += cho[i];
  writeln(ans);
  for (int i = 1; i <= n; i++)
    if (cho[i]) write(i), putchar(' ');
}
int main() {
  init();
  solve();
  return 0;
}
