#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int N, M, cnt;
bool used[MAXN], del[MAXN];
struct node {
  int v, next;
} E[MAXN];
int head[MAXN], Elen;
void add(int u, int v) {
  ++Elen, E[Elen].v = v, E[Elen].next = head[u], head[u] = Elen;
}
int main() {
  scanf("%d%d", &N, &M);
  int u, v;
  for (int i = 1; i <= M; ++i) scanf("%d%d", &u, &v), add(u, v);
  for (int i = 1; i <= N; ++i)
    if (!del[i]) {
      used[i] = 1;
      for (int j = head[i]; j; j = E[j].next) del[E[j].v] = 1;
    }
  for (int i = N; i >= 1; --i)
    if (used[i]) {
      for (int j = head[i]; j; j = E[j].next)
        if (used[E[j].v]) used[E[j].v] = 0;
    }
  for (int i = 1; i <= N; ++i)
    if (used[i]) ++cnt;
  printf("%d\n", cnt);
  for (int i = 1; i <= N; ++i)
    if (used[i]) printf("%d ", i);
  return 0;
}
