#include <bits/stdc++.h>
using namespace std;
vector<int> a[1000010], ans, b[1000010];
int vis[1000010], viss[1000010];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    b[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      vis[i] = 1;
      viss[i] = 1;
      for (int j = 0; j < a[i].size(); j++) {
        vis[a[i][j]] = 1;
      }
    }
  }
  for (int i = n; i; i--) {
    if (viss[i] == 1) {
      for (int j = 0; j < b[i].size(); j++)
        if (viss[b[i][j]] == 1) viss[i] = 0;
    }
  }
  for (int i = 1; i <= n; i++)
    if (viss[i]) ans.push_back(i);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
}
