#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
vector<int> a[maxn], ans, b[maxn];
int n, m, hav[maxn], book[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    b[y].push_back(x);
  }
  memset(book, 0, sizeof book);
  memset(hav, 0, sizeof hav);
  for (int i = 1; i <= n; i++)
    if (book[i] == 0) {
      book[i] = hav[i] = 1;
      for (int j = 0; j < a[i].size(); j++) book[a[i][j]] = 1;
    }
  for (int i = n; i; i--)
    if (hav[i] == 1) {
      for (int j = 0; j < b[i].size(); j++)
        if (hav[b[i][j]] == 1) hav[i] = 0;
    }
  for (int i = 1; i <= n; i++)
    if (hav[i]) ans.push_back(i);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
