#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000005;
int n, m, ed, fir[maxN];
int del[maxN];
struct Edge {
  int v, nxt;
} e[maxN];
void adde(int x, int y) {
  e[++ed].v = y;
  e[ed].nxt = fir[x];
  fir[x] = ed;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    adde(x, y);
  }
  for (int x = 1; x <= n; x++)
    if (!del[x]) {
      for (int i = fir[x]; i; i = e[i].nxt)
        if (e[i].v > x) {
          del[e[i].v] = 1;
        }
    }
  vector<int> ans;
  for (int x = n; x; x--)
    if (!del[x]) {
      ans.push_back(x);
      for (int i = fir[x]; i; i = e[i].nxt) {
        del[e[i].v] = 1;
      }
    }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int((ans).size())));
  for (int i = 0; i < (int((ans).size())); i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
