#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
inline void solve(), read();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read();
  solve();
  return 0;
}
struct graph {
  long long n;
  vector<vector<long long> > adj;
  graph() {}
  graph(long long n_) {
    n = n_;
    adj.resize(n);
  }
  void insert(long long v, long long u) { adj[v].push_back(u); }
};
long long n, m;
graph g;
vector<long long> die, good;
inline void solve() {
  die.resize(n);
  good.resize(n);
  for (long long v = 0; v < n; v++) {
    if (die[v]) {
      continue;
    }
    good[v] = 1;
    for (long long u : g.adj[v]) {
      die[u] = 1;
    }
  }
  die.assign(n, 0);
  vector<long long> ans;
  for (long long v = n - 1; v >= 0; v--) {
    if (!good[v]) {
      continue;
    }
    if (die[v]) {
      continue;
    }
    ans.push_back(v);
    for (long long u : g.adj[v]) {
      die[u] = 1;
    }
  }
  cout << (long long)((ans).size()) << "\n";
  for (long long v : ans) {
    cout << v + 1 << " ";
  }
  cout << "\n";
}
inline void read() {
  cin >> n >> m;
  g = graph(n);
  for (long long i = 0; i < m; i++) {
    long long v, u;
    cin >> v >> u;
    --v, --u;
    g.insert(v, u);
  }
}
