#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, m, be[maxn], k, ans[maxn], vis[maxn];
vector<int> G[maxn];
inline int read() {
  char ch = getchar();
  int u = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    u = u * 10 + ch - 48;
    ch = getchar();
  }
  return u * f;
}
int main() {
  n = read();
  m = read();
  for (register int i = 1; i <= m; i++) {
    int x = read(), y = read();
    G[x].push_back(y);
  }
  for (register int i = 1; i <= n; i++) {
    if (be[i]) continue;
    be[i] = i;
    for (vector<int>::iterator u = G[i].begin(); u != G[i].end(); u++)
      if (!be[*u]) be[*u] = i;
  }
  for (register int i = n; i >= 1; i--) {
    if (vis[i] || be[i] != i) continue;
    ans[++k] = i;
    for (vector<int>::iterator u = G[i].begin(); u != G[i].end(); u++)
      vis[*u] = 1;
  }
  printf("%d\n", k);
  for (register int i = 1; i <= k; i++) printf("%d ", ans[i]);
  return 0;
}
