#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
  }
  vector<int> color(n);
  for (int i = 0; i < n; i++) {
    if (color[i] == 0) {
      color[i] = 1;
      for (int j : g[i])
        if (j > i) color[j] = -1;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (color[i] == 1) {
      for (int j : g[i])
        if (j < i) color[j] = -1;
    }
  }
  cout << count(color.begin(), color.end(), 1) << endl;
  for (int i = 0; i < n; i++) {
    if (color[i] == 1) {
      printf("%d ", i + 1);
    }
  }
}
