#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int To[N], Ne[N], St[N], Tor[N], Ner[N], Str[N], en;
inline __attribute__((always_inline)) void getedge() {
  int u, v;
  scanf("%d%d", &u, &v);
  To[++en] = v, Ne[en] = St[u], St[u] = en;
  Tor[en] = u, Ner[en] = Str[v], Str[v] = en;
}
bool f[N], s[N];
int p;
vector<int> ans;
void solve(int n) {
  if (n == 0) return;
  while (f[p]) ++p;
  int u = p, cnt = 1;
  f[u] = 1;
  for (int i = St[u]; i; i = Ne[i])
    if (!f[To[i]]) f[To[i]] = 1, ++cnt;
  solve(n - cnt);
  bool can = 1;
  for (int i = Str[u]; i; i = Ner[i])
    if (s[Tor[i]]) can = 0;
  if (can) s[u] = 1, ans.push_back(u);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  while (m--) getedge();
  p = 1, solve(n);
  printf("%u\n", ans.size());
  for (int x : ans) printf("%d ", x);
  return 0;
}
