#include <bits/stdc++.h>
long long gi() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
std::mt19937 rnd(time(NULL));
template <class T>
void cxk(T& a, T b) {
  a = a > b ? a : b;
}
template <class T>
void cnk(T& a, T b) {
  a = a < b ? a : b;
}
bool in[1000010], del[1000010];
std::vector<int> G[1000010];
int main() {
  int n = gi(), m = gi(), a, b;
  for (int i = 1; i <= m; ++i) a = gi(), b = gi(), G[a].push_back(b);
  for (int i = 1; i <= n; ++i)
    if (!del[i]) {
      in[i] = 1;
      for (int j : G[i]) del[j] = 1;
    }
  for (int i = n; i; --i)
    if (in[i]) {
      for (int j : G[i]) in[j] = 0;
    }
  int s = 0;
  for (int i = 1; i <= n; ++i) s += in[i];
  printf("%d\n", s);
  for (int i = 1; i <= n; ++i)
    if (in[i]) printf("%d ", i);
  return 0;
}
