#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, ans;
int v[1000100];
vector<int> head[1000100];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) a = read(), b = read(), head[a].push_back(b);
  for (int i = 1; i <= n; i++) {
    if (v[i]) continue;
    int sz = head[i].size();
    v[i] = -1;
    for (int j = 0; j < sz; j++) {
      if (v[head[i][j]]) continue;
      v[head[i][j]] = 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (v[i] == 1) continue;
    ans++;
    int sz = head[i].size();
    for (int j = 0; j < sz; j++) v[head[i][j]] = 1;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++)
    if (v[i] == -1) cout << i << " ";
  return 0;
}
