#include <bits/stdc++.h>
using namespace std;
namespace Fread {
const int MAXN = 1 << 20;
char buf[MAXN], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, MAXN, stdin);
    if (S == T) return EOF;
  }
  return *S++;
}
}  // namespace Fread
namespace Fwrite {
const int MAXN = 1 << 20;
char buf[MAXN], *S = buf, *T = buf + MAXN;
inline void flush() {
  fwrite(buf, 1, S - buf, stdout);
  S = buf;
}
inline void putchar(char c) {
  *S++ = c;
  if (S == T) flush();
}
struct _ {
  ~_() { flush(); }
} __;
}  // namespace Fwrite
template <typename T>
inline void read(T& x) {
  x = 0;
  int f = 1;
  char c = Fread::getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = Fread::getchar();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ '0'), c = Fread::getchar();
  x *= f;
}
template <typename T>
inline void write(T x, bool _enter = 0, bool _space = 0) {
  if (!x)
    Fwrite::putchar('0');
  else {
    if (x < 0) Fwrite::putchar('-'), x = -x;
    static char dig[41];
    int top = 0;
    while (x) dig[++top] = (x % 10) ^ '0', x /= 10;
    while (top) Fwrite::putchar(dig[top--]);
  }
  if (_enter) Fwrite::putchar('\n');
  if (_space) Fwrite::putchar(' ');
}
namespace Fastio {
struct reader {
  template <typename T>
  reader& operator>>(T& x) {
    ::read(x);
    return *this;
  }
  reader& operator>>(char& c) {
    c = Fread::getchar();
    while (c == '\n' || c == ' ') c = Fread::getchar();
    return *this;
  }
  reader& operator>>(char* str) {
    int len = 0;
    char c = Fread::getchar();
    while (c == '\n' || c == ' ') c = Fread::getchar();
    while (c != '\n' && c != ' ') str[len++] = c, c = Fread::getchar();
    str[len] = '\0';
    return *this;
  }
  reader& operator>>(std::string& s) {
    std::cin >> s;
    return *this;
  }
} cin;
const char endl = '\n';
struct writer {
  template <typename T>
  writer& operator<<(T x) {
    ::write(x, 0, 0);
    return *this;
  }
  writer& operator<<(char c) {
    Fwrite::putchar(c);
    return *this;
  }
  writer& operator<<(const char* str) {
    int cur = 0;
    while (str[cur]) Fwrite::putchar(str[cur++]);
    return *this;
  }
} cout;
}  // namespace Fastio
const int MAXN = 1e6;
int n, m;
vector<int> G[MAXN + 5], R[MAXN + 5];
bool del[MAXN + 5], ch[MAXN + 5];
void dfs(int u) {
  if (u == n + 1) {
    return;
  }
  if (del[u]) {
    dfs(u + 1);
    return;
  }
  del[u] = 1;
  for (int i = 0; i < ((int)(G[u]).size()); ++i) {
    int v = G[u][i];
    del[v] = 1;
  }
  dfs(u + 1);
  for (int i = 0; i < ((int)(R[u]).size()); ++i) {
    int v = R[u][i];
    if (ch[v]) {
      ch[u] = 0;
      return;
    }
  }
  ch[u] = 1;
  return;
}
int main() {
  Fastio::cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    Fastio::cin >> u >> v;
    G[u].push_back(v);
    R[v].push_back(u);
  }
  dfs(1);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if (ch[i]) ans++;
  Fastio::cout << ans << Fastio::endl;
  for (int i = 1; i <= n; ++i)
    if (ch[i]) Fastio::cout << i << " ";
  Fastio::cout << Fastio::endl;
  return 0;
}
