#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> Edg[1000005];
bool vis[1000005];
vector<int> ans;
template <typename Drake>
void read(Drake &x) {
  x = 0;
  char ch = getchar();
  bool f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f ^= 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x *= (2 * f - 1);
}
template <typename Drake>
void write(Drake x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename Drake>
void writeln(Drake x) {
  write(x);
  puts("");
}
void init() {
  ans.clear();
  read(n);
  read(m);
  int u, v;
  for (int i = 1; i <= m; ++i) {
    read(u);
    read(v);
    Edg[u].push_back(v);
  }
}
int main() {
  init();
  register int i, j;
  for (i = 1; i <= n; ++i)
    if (!vis[i]) {
      for (j = 0; j < Edg[i].size(); ++j)
        if (Edg[i][j] > i) vis[Edg[i][j]] = 1;
    }
  for (i = n; i >= 1; --i)
    if (!vis[i]) {
      for (j = 0; j < Edg[i].size(); ++j) vis[Edg[i][j]] = 1;
      ans.push_back(i);
    }
  writeln(ans.size());
  write(ans[0]);
  for (int i = 1; i < ans.size(); ++i) putchar(' '), write(ans[i]);
  puts("");
  return 0;
}
