#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e13, Mo = 998244353;
const int N = 1000000;
const double eps = 1e-6;
namespace slow_IO {
long long read() {
  long long x = 0;
  int zf = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') zf = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * zf;
}
void write(long long y) {
  if (y < 0) putchar('-'), y = -y;
  if (y > 9) write(y / 10);
  putchar(y % 10 + '0');
}
}  // namespace slow_IO
using namespace slow_IO;
vector<int> E1[N + 5], E2[N + 5];
int Flag1[N + 5], Flag2[N + 5];
int Ans[N + 5];
int ans = 0;
int main() {
  int n = read(), m = read();
  for (int i = (1); i <= (m); i++) {
    int x = read(), y = read();
    E1[x].push_back(y);
    E2[y].push_back(x);
  }
  for (int i = (1); i <= (n); i++)
    if (!Flag1[i]) {
      Flag1[i] = Flag2[i] = 1;
      for (int j = (0); j < (E1[i].size()); j++) Flag1[E1[i][j]] = 1;
    }
  for (int i = (n); i >= (1); i--)
    if (Flag2[i]) {
      for (int j = (0); j < (E2[i].size()); j++)
        if (Flag2[E2[i][j]]) Flag2[i] = 0;
    }
  for (int i = (1); i <= (n); i++)
    if (Flag2[i]) Ans[++ans] = i;
  printf("%d\n", ans);
  for (int i = (1); i <= (ans); i++)
    printf("%d%c", Ans[i], i == ans ? '\n' : ' ');
  return 0;
}
