#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 5;
vector<int> g[N], revg[N], cur;
bool used[N], isans[N];
set<int> all;
int n, m;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    g[u].push_back(v);
    revg[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    all.insert(i);
  }
  while (!all.empty()) {
    int k = *(all.begin());
    for (auto x : g[k]) {
      if (!used[x]) {
        used[x] = true;
        all.erase(x);
      }
    }
    used[k] = true;
    all.erase(k);
    cur.push_back(k);
  }
  for (int i = cur.size() - 1; i >= 0; i--) {
    int node = cur[i];
    isans[node] = true;
    for (auto x : revg[node]) {
      if (isans[x]) {
        isans[node] = false;
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (isans[i]) ans.push_back(i + 1);
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
