#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 11;
vector<int> to[N];
int n, m, x, y, ans, vis[N], used[N];
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    to[x].push_back(y);
  }
  for (register int i = 1; i <= n; ++i)
    if (!vis[i]) {
      vis[i] = 1;
      for (auto v : to[i]) vis[v] = 1;
      used[i] = 1;
    }
  for (register int i = n; i >= 1; --i)
    if (used[i]) {
      ++ans;
      for (auto v : to[i]) used[v] = 0;
    }
  printf("%d\n", ans);
  for (register int i = 1; i <= n; ++i)
    if (used[i]) printf("%d ", i);
  puts("");
  return 0;
}
