#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000005;
int n, m, flag[Maxn], ok[Maxn];
vector<int> g[Maxn], rg[Maxn], ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    rg[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i)
    if (!flag[i]) {
      flag[i] = ok[i] = 1;
      for (int j = 0; j < g[i].size(); ++j) flag[g[i][j]] = 1;
    }
  for (int i = n; i--;)
    if (ok[i])
      for (int j = 0; j < rg[i].size(); ++j)
        if (ok[rg[i][j]]) ok[i] = 0;
  for (int i = 1; i <= n; ++i)
    if (ok[i]) ans.push_back(i);
  printf("%d\n%d", (int)ans.size(), ans[0]);
  for (int i = 1; i < ans.size(); ++i) printf(" %d", ans[i]);
  putchar('\n');
  return 0;
}
