#include <bits/stdc++.h>
using namespace std;
int del[1000010];
vector<int> g[1000010], ans;
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) {
    if (!del[i]) {
      for (auto j : g[i])
        if (j > i) del[j] = 1;
    }
  }
  for (int i = n; i >= 1; --i) {
    if (!del[i]) {
      ans.push_back(i);
      for (auto j : g[i]) del[j] = 1;
    }
  }
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d ", i);
  putchar(10);
  return 0;
}
