#include <bits/stdc++.h>
using std::vector;
const int MAXN = 1e6 + 20;
namespace MyIO {
const int MAXB = 1 << 18;
char gbuf[MAXB], *ps = gbuf, *pt = gbuf;
char pbuf[MAXB + 1], *pp = pbuf;
struct Flusher {
  ~Flusher() { fwrite(pbuf, 1, pp - pbuf, stdout); }
} flusher;
inline char Getchar() {
  if (ps == pt) {
    ps = gbuf;
    pt = gbuf + fread(gbuf, 1, MAXB, stdin);
  }
  return (ps == pt) ? EOF : *ps++;
}
inline void Putchar(const char &ch) {
  if (pp == pbuf + MAXB) {
    pp = pbuf;
    fwrite(pbuf, 1, MAXB, stdout);
  }
  *pp++ = ch;
}
}  // namespace MyIO
int read() {
  int x = 0;
  char c = MyIO::Getchar();
  bool f = 0;
  while (c < '0' || c > '9')
    (c == '-') ? f = 1, c = MyIO::Getchar() : c = MyIO::Getchar();
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (48 ^ c), c = MyIO::Getchar();
  return (f) ? -x : x;
}
void write(const int &x) {
  if (x / 10) write(x / 10);
  MyIO::Putchar('0' + x % 10);
}
vector<int> E[MAXN];
bool vis[MAXN], chosen[MAXN];
int main() {
  int n = read(), m = read();
  for (int i = 0; i < m; ++i) {
    int u = read(), v = read();
    E[u].push_back(v);
  }
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      if (chosen[i] == 0) ++cnt;
      chosen[i] = 1;
      vis[i] = 1;
      for (int j : E[i]) vis[j] = 1;
    }
  for (int i = n; i >= 1; --i)
    if (chosen[i])
      for (int j : E[i]) {
        if (chosen[j] == 1) --cnt;
        chosen[j] = 0;
      }
  write(cnt), MyIO::Putchar('\n');
  for (int i = 1; i <= n; ++i)
    if (chosen[i]) write(i), MyIO::Putchar(' ');
}
