#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1000001];
vector<int> edges_rev[1000001];
bool isv[1000001];
stack<int> s;
int n, m;
void read_data() {
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    edges[u].push_back(v);
    edges_rev[v].push_back(u);
  }
}
int main() {
  read_data();
  memset(isv, 0, sizeof(isv));
  for (int u = 1; u <= n; u++)
    if (!isv[u]) {
      isv[u] = true;
      s.push(u);
      for (auto &v : edges[u]) isv[v] = true;
    }
  vector<int> ans;
  memset(isv, 0, sizeof(isv));
  while (!s.empty()) {
    int u = s.top();
    s.pop();
    if (ans.size() == 0) {
      isv[u] = true;
      ans.push_back(u);
      continue;
    }
    bool flag = false;
    for (auto &v : edges_rev[u]) flag |= isv[v];
    if (!flag) {
      isv[u] = true;
      ans.push_back(u);
    }
  }
  cout << ans.size() << endl;
  for (auto &u : ans) cout << u << ' ';
  cout << endl;
  return 0;
}
