#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m;
bool tag[N], in[N];
vector<int> g[N], o;
int main() {
  scanf("%d%d", &n, &m);
  register int i, u, v;
  while (m--) scanf("%d%d", &u, &v), g[u].push_back(v);
  for (i = 1; i <= n; ++i)
    if (!tag[i]) {
      tag[i] = in[i] = 1;
      for (const int &j : g[i]) tag[j] = 1;
    }
  for (i = n; i; --i)
    if (in[i])
      for (const int &j : g[i]) in[j] = 0;
  for (i = 1; i <= n; ++i)
    if (in[i]) o.push_back(i);
  printf("%d\n", o.size());
  for (const int &i : o) printf("%d ", i);
  return 0;
}
