#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 1e6 + 5;
int n, m;
bool v[N], exi[N];
vector<int> ans, g[N];
signed main() {
  read(n, m);
  for (int i = 1, x, y; i <= m; i++) {
    read(x, y);
    g[x].push_back(y);
  }
  for (int i = 1; i <= n; i++)
    if (!v[i]) {
      v[i] = exi[i] = 1;
      for (int y : g[i]) v[y] = 1;
    }
  for (int i = n; i; i--)
    if (exi[i])
      for (int y : g[i]) exi[y] = 0;
  for (int i = 1; i <= n; i++)
    if (exi[i]) ans.push_back(i);
  write(ans.size());
  puts("");
  for (int x : ans) write(x), putchar(' ');
}
