#include <bits/stdc++.h>
using namespace std;
const int N = 1111111;
vector<int> graph[N];
bool rem[N], is[N], re[N];
int n, m;
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = (1); i <= (m); i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
  }
  vector<int> add;
  for (int i = (1); i <= (n); i++) {
    if (!rem[i]) {
      add.push_back(i);
      rem[i] = true;
      for (auto j : graph[i]) {
        rem[j] = true;
      }
    }
  }
  reverse(add.begin(), add.end());
  vector<int> ans;
  for (auto u : add) {
    if (!re[u]) {
      is[u] = true;
      re[u] = true;
      ans.push_back(u);
      for (auto v : graph[u]) {
        re[v] = true;
      }
    }
  }
  cout << (int)(ans).size() << "\n";
  for (auto x : ans) {
    cout << x << " ";
  }
  cout << "\n";
  return 0;
}
