#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int next;
  int to;
} edge[1000005];
int head[1000005];
bool used[1000005];
bool vis[1000005];
int cnt = 1;
int n, m;
void init() {
  memset(head, -1, sizeof(head));
  cnt = 1;
}
void add(int l, int r) {
  edge[cnt].next = head[l];
  edge[cnt].to = r;
  head[l] = cnt++;
}
int main() {
  scanf("%d%d", &n, &m);
  init();
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      vis[i] = 1;
      used[i] = 1;
      for (int j = head[i]; j != -1; j = edge[j].next) {
        int to = edge[j].to;
        used[to] = 1;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (vis[i]) {
      for (int j = head[i]; j != -1; j = edge[j].next) {
        int to = edge[j].to;
        vis[to] = 0;
      }
    }
  }
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      ret++;
    }
  }
  printf("%d\n", ret);
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      printf("%d ", i);
    }
  }
  return 0;
}
