#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, tot;
int head[1000005];
bool vis[1000005];
bool usd[1000005];
int ans[1000005];
struct Edge {
  int fr;
  int to;
  int nxt;
} edge[1000005];
void init() { memset(head, -1, sizeof(head)); }
void addedge(int f, int t) {
  cnt++;
  edge[cnt].fr = f;
  edge[cnt].to = t;
  edge[cnt].nxt = head[f];
  head[f] = cnt;
}
int main() {
  init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = usd[i] = true;
      for (int j = head[i]; j != -1; j = edge[j].nxt) {
        int v = edge[j].to;
        vis[v] = true;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (usd[i]) {
      for (int j = head[i]; j != -1; j = edge[j].nxt) {
        int v = edge[j].to;
        usd[v] = false;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (usd[i]) ans[++tot] = i;
  }
  printf("%d\n", tot);
  for (int i = 1; i <= tot; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
