#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int INF = 1e9;
int N, M;
int dead[MAXN];
vector<int> V[MAXN];
set<int> in, ans, reach;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M;
  int a, b;
  for (int i = (0); i < (M); i++) {
    cin >> a >> b;
    a--;
    b--;
    V[a].push_back(b);
  }
  for (int i = (0); i < (N); i++) {
    if (!dead[i]) {
      dead[i] = 1;
      for (auto &k : V[i]) dead[k] = 1;
      in.insert(i);
    }
  }
  for (auto it = in.rbegin(); it != in.rend(); it++) {
    if (reach.find(*it) == reach.end()) {
      ans.insert(*it);
      reach.insert(*it);
      for (auto &k : V[*it]) reach.insert(k);
    }
  }
  cout << ans.size() << '\n';
  for (auto &k : ans) {
    cout << k + 1 << ' ';
  }
  return 0;
}
