#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
using namespace std;
long long poww(long long a, long long b, long long md) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 1000 * 1000 + 5;
const long long inf = 9223372036854775807;
const long long mod = 1e9 + 7;
const int lg = 20;
int n, m, mark[maxn];
vector<int> ans, ANS;
vector<int> adj[maxn];
set<int> s, t;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) {
      mark[i] = 1;
      ans.push_back(i);
      for (auto u : adj[i]) {
        if (!mark[u]) {
          mark[u] = 1;
        }
      }
    }
  }
  memset(mark, 0, sizeof mark);
  reverse((ans).begin(), (ans).end());
  for (auto u : ans) {
    if (mark[u]) continue;
    ANS.push_back(u);
    for (auto v : adj[u]) {
      mark[v] = 1;
    }
  }
  cout << (long long)(ANS).size() << endl;
  for (auto u : ANS) cout << u << " ";
}
