#include <bits/stdc++.h>
const int N = 1000005;
int n, m, vis[N], usd[N];
std::vector<int> g[N], ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i) {
    if (vis[i] != 0) continue;
    vis[i] = -1;
    for (int v : g[i])
      if (vis[v] == 0) vis[v] = 1;
  }
  for (int i = n; i >= 1; --i) {
    if (vis[i] != -1 || usd[i]) continue;
    ans.push_back(i);
    for (int v : g[i]) usd[v] = 1;
  }
  printf("%lu\n", ans.size());
  for (int v : ans) printf("%d ", v);
  return 0;
}
