#include <bits/stdc++.h>
using namespace std;
struct bian {
  int l, r;
} a[1500000];
int fir[1500000];
int nex[1500000];
int tot = 1;
void add_edge(int l, int r) {
  a[++tot].l = l;
  a[tot].r = r;
  nex[tot] = fir[l];
  fir[l] = tot;
}
bool del[1500000];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    add_edge(l, r);
  }
  for (int i = 1; i <= n; i++) {
    if (del[i]) continue;
    for (int o = fir[i]; o; o = nex[o])
      if (a[o].r > i) del[a[o].r] = true;
  }
  for (int i = n; i >= 1; i--) {
    if (del[i]) continue;
    for (int o = fir[i]; o; o = nex[o]) del[a[o].r] = true;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!del[i]) ans++;
  cout << ans << endl;
  for (int i = 1; i <= n; i++)
    if (!del[i]) printf("%d ", i);
  return 0;
}
