#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
const int maxn = 1000005;
int n, m;
vector<int> edge[maxn], ans;
bool del[maxn];
int main() {
  n = rd(), m = rd();
  for (register int i = (1); i <= int(n); ++i) edge[i].clear();
  for (register int i = (1); i <= int(m); ++i) {
    int x = rd(), y = rd();
    edge[x].push_back(y);
  }
  for (register int i = (1); i <= int(n); ++i)
    if (!del[i]) {
      for (register int j = (0); j < int(edge[i].size()); ++j)
        if (edge[i][j] > i) {
          del[edge[i][j]] = true;
        }
    }
  for (register int i = (n); i >= int(1); --i)
    if (!del[i]) {
      ans.push_back(i);
      for (register int j = (0); j < int(edge[i].size()); ++j)
        del[edge[i][j]] = true;
    }
  writeln(ans.size());
  for (register int i = (0); i < int(ans.size()); ++i) {
    printf("%d ", ans[i]);
  }
  puts("");
}
