#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e6;
int n;
bool f[nmax + 1], out[nmax + 1];
vector<int> sol;
vector<int> intra[nmax + 1], ies[nmax + 1];
void solve(int nod) {
  if (nod == n + 1) return;
  if (out[nod] == 1) {
    solve(nod + 1);
    return;
  }
  for (auto i : ies[nod]) out[i] = 1;
  solve(nod + 1);
  int ok = 0;
  for (auto i : intra[nod]) ok |= f[i];
  if (ok == 0) {
    f[nod] = 1;
    sol.push_back(nod);
  }
}
int main() {
  int m;
  fscanf(stdin, "%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    fscanf(stdin, "%d%d", &x, &y);
    ies[x].push_back(y);
    intra[y].push_back(x);
  }
  solve(1);
  fprintf(stdout, "%d\n", (int)sol.size());
  for (auto i : sol) fprintf(stdout, "%d ", i);
  fprintf(stdout, "\n");
  return 0;
}
