#include <bits/stdc++.h>
#pragma warning(disable : 4996)
FILE *in = stdin, *out = stdout;
using namespace std;
int n, m, candidate[1000005], visit[1000005];
vector<int> con[1000005], ans;
void input() {
  fscanf(in, "%d", &n), fscanf(in, "%d", &m);
  for (int i = (1); i <= (m); i++) {
    int x, y;
    fscanf(in, "%d", &x), fscanf(in, "%d", &y);
    con[x].push_back(y);
  }
}
void pro() {
  for (int i = (1); i <= (n); i++) {
    if (visit[i]) continue;
    visit[i] = 1;
    candidate[i] = 1;
    for (auto &y : con[i]) visit[y] = 1;
  }
  for (int i = (1); i <= (n); i++) visit[i] = 0;
  for (int i = n; i >= 1; i--) {
    if (!candidate[i] || visit[i]) continue;
    ans.push_back(i);
    for (auto &y : con[i]) visit[y] = 1;
  }
  fprintf(out, "%d\n", ans.size());
  for (auto &x : ans) fprintf(out, "%d ", x);
}
int main() {
  input();
  pro();
  return 0;
}
