#include <bits/stdc++.h>
using namespace std;
const int N = 1000002;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  x *= f;
}
int n, m, vis[N], use[N];
vector<int> d[N], p[N], ans;
int main() {
  read(n), read(m);
  static int u, v;
  while (m--) {
    read(u), read(v);
    d[u].push_back(v), p[v].push_back(u);
  }
  for (int u = 1; u <= n; ++u)
    if (!vis[u]) {
      vis[u] = use[u] = 1;
      for (int v : d[u]) vis[v] = 1;
    }
  for (int u = n; u; --u)
    if (use[u])
      for (int v : p[u])
        if (use[v]) {
          use[u] = 0;
          break;
        }
  for (int i = 1; i <= n; ++i)
    if (use[i]) ans.push_back(i);
  printf("%d\n", ans.size());
  for (int x : ans) printf("%d ", x);
  return 0;
}
