#include <bits/stdc++.h>
using namespace std;
int n, m, first[1001000], ds[1001000], bb, bj[1001000];
bool ok[1001000];
struct Bn {
  int to, next;
} bn[1001000 << 1];
vector<int> ans;
inline void add(int u, int v) {
  bb++;
  bn[bb].to = v;
  bn[bb].next = first[u];
  first[u] = bb;
}
int main() {
  memset(first, -1, sizeof(first));
  int i, j, o, p, q, t;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &p, &q);
    add(p, q);
  }
  for (i = 1; i <= n; i++) {
    if (bj[i]) continue;
    bj[i] = 1;
    for (p = first[i]; p != -1; p = bn[p].next) {
      if (!bj[bn[p].to]) {
        bj[bn[p].to] = -1;
      }
    }
  }
  for (i = n; i >= 1; i--) {
    if (bj[i] != 1 || ok[i]) continue;
    ans.push_back(i);
    for (p = first[i]; p != -1; p = bn[p].next) {
      bj[bn[p].to] = -1;
    }
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
}
