#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
long long n, m, x, y, cnt, ans;
bool del[N], ch[N];
vector<long long> out[N], in[N];
void dfs(long long x) {
  if (x > n) return;
  if (del[x]) {
    dfs(x + 1);
    return;
  }
  del[x] = 1;
  for (long long y : out[x]) del[y] = 1;
  dfs(x + 1);
  for (long long y : in[x])
    if (ch[y]) {
      ch[x] = 0;
      return;
    }
  ch[x] = 1;
  return;
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    out[x].push_back(y);
    in[y].push_back(x);
  }
  dfs(1);
  for (long long i = 1; i <= n; i++) ans += ch[i];
  printf("%lld\n", ans);
  for (long long i = 1; i <= n; i++)
    if (ch[i]) printf("%lld ", i);
  puts("");
  return 0;
}
