#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> sons;
  vector<int> father;
} mapper[1000005];
bool vis[1000005];
bool mark[1000005];
set<int> ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    mapper[a].sons.push_back(b);
    mapper[b].father.push_back(a);
  }
  memset(vis, 0, sizeof vis);
  memset(mark, 0, sizeof mark);
  for (int i = n; i > 0; i--) {
    if (!vis[i]) {
      vis[i] = true;
      mark[i] = true;
      for (int j = 0; j < mapper[i].sons.size(); j++) {
        vis[mapper[i].sons[j]] = true;
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    if (mark[i]) {
      for (int j = 0; j < mapper[i].father.size(); j++) {
        if (mark[mapper[i].father[j]]) {
          mark[i] = false;
          break;
        }
      }
      if (mark[i]) ans.insert(i);
    }
  }
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it << "  ";
  }
  return 0;
}
