#include <bits/stdc++.h>
#pragma GCC optimize("O2,unroll-loops")
using namespace std;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 1000010, LOG = 20;
int n, m, k, u, v, x, y, t, a, b, ans;
int mark[MAXN];
vector<int> G[MAXN], out;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  while (m--) {
    cin >> u >> v;
    G[u].push_back(v);
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      mark[i] = 1;
      for (int j : G[i])
        if (i < j) mark[j] = 2;
    }
  for (int i = n; i; i--)
    if (mark[i] == 1) {
      out.push_back(i);
      for (int j : G[i])
        if (j < i) mark[j] = 3;
    }
  cout << out.size() << "\n";
  for (int v : out) cout << v << " ";
  cout << "\n";
  return 0;
}
