#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6;
vector<int> adj[MAX], back_adj[MAX];
unordered_set<int> available;
bool in_Q[MAX];
int removed[MAX];
int n, m;
void roll() {
  if (available.empty()) {
    return;
  }
  int node = *available.begin();
  available.erase(available.begin());
  for (auto &each : adj[node]) {
    if (available.count(each)) {
      available.erase(each);
    }
  }
  roll();
  bool someone_in_Q = false;
  for (auto &each : back_adj[node]) {
    someone_in_Q |= in_Q[each];
  }
  if (!someone_in_Q) {
    in_Q[node] = true;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = int(1); i < int(m + 1); i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    back_adj[v].push_back(u);
  }
  for (int i = int(1); i < int(n + 1); i++) {
    available.insert(i);
  }
  roll();
  int total = 0;
  for (int i = int(1); i < int(n + 1); i++) {
    total += in_Q[i];
  }
  printf("%d\n", total);
  for (int i = int(1); i < int(n + 1); i++) {
    if (in_Q[i]) {
      printf("%d ", i);
    }
  }
  puts("");
  return 0;
}
