#include <bits/stdc++.h>
using namespace std;
int T, n, m;
vector<int> E[1000010], ans;
bool vis[1000010], ok[1000010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= m; i++) scanf("%d%d", &u, &v), E[u].push_back(v);
  for (int i = 1; i <= n; i++)
    if (!ok[i]) {
      ok[i] = vis[i] = true;
      for (auto v : E[i]) ok[v] = true;
    }
  for (int i = n; i >= 1; i--)
    if (vis[i]) {
      for (auto v : E[i]) vis[v] = false;
    }
  for (int i = 1; i <= n; i++)
    if (vis[i]) ans.push_back(i);
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d ", i);
  puts("");
}
