#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast", "-funroll-all-loops")
using namespace std;
const int N = 1e6 + 10;
int n, m, vis[N], st[N];
vector<int> g[N], res;
signed main() {
  cin >> n >> m;
  for (int i = 1, a, b; i <= m; i++) scanf("%d %d", &a, &b), g[a].push_back(b);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      vis[i] = st[i] = 1;
      for (int j = 0; j < g[i].size(); j++) vis[g[i][j]] = 1;
    }
  for (int i = n; i >= 1; i--)
    if (st[i]) {
      for (int j = 0; j < g[i].size(); j++) st[g[i][j]] = 0;
    }
  for (int i = 1; i <= n; i++)
    if (st[i]) res.push_back(i);
  cout << res.size() << '\n';
  for (auto x : res) printf("%d ", x);
  return 0;
}
