#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int vis[maxn], tag[maxn], ind[maxn];
vector<int> vec[maxn];
queue<int> q;
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    vec[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    for (int it : vec[i])
      if (it > i) ind[it]++;
  }
  for (int i = 1; i <= n; i++)
    if (!ind[i]) q.push(i);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (vis[x]) continue;
    tag[x] = 1;
    for (int it : vec[x]) {
      if (it > x && !vis[it]) {
        vis[it] = 1;
        for (int it2 : vec[it]) {
          if (it < it2 && --ind[it2] == 0) q.push(it2);
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int it : vec[i]) {
      if (it < i && tag[i] && tag[it]) tag[it] = 0;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (tag[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (tag[i]) printf("%d ", i);
  printf("\n");
}
int main(void) {
  solve();
  return 0;
}
