#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
bool has[MAXN];
vector<int> E[MAXN], RE[MAXN];
set<int> P;
void solve() {
  if (P.empty()) return;
  int x = *P.begin();
  P.erase(x);
  for (int y : E[x]) {
    P.erase(y);
  }
  solve();
  bool bad = false;
  for (int y : RE[x]) {
    bad |= has[y];
  }
  if (!bad) has[x] = true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    E[a].push_back(b);
    RE[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) P.insert(i);
  solve();
  vector<int> ans;
  for (int i = 1; i <= n; ++i)
    if (has[i]) ans.push_back(i);
  printf("%d\n", ans.size());
  for (int a : ans) printf("%d ", a);
}
