#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
vector<int> g[N];
int was[N];
bool Q[N];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
  }
  for (int u = 1; u <= n; u++) {
    if (!was[u]) {
      was[u] = 1;
      for (int v : g[u]) {
        if (!was[v]) was[v] = 2;
      }
    }
  }
  int k = 0;
  for (int u = n; u >= 1; u--) {
    if (was[u] == 1) {
      k++;
      Q[u] = true;
      for (int v : g[u]) {
        was[v] = 2;
      }
    }
  }
  printf("%d\n", k);
  for (int u = 1; u <= n; u++) {
    if (Q[u]) printf("%d ", u);
  }
  return 0;
}
