#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const double Eps = 1e-7;
const int N = 2e6 + 9;
int head[2][N], tot, n, m, u, v;
bool vis[N], used[N];
;
void init() {
  tot = 0;
  memset(head, -1, sizeof head);
}
struct node {
  int to, nex;
} edge[N];
void addedge(int u, int v, int id) {
  edge[tot] = node{v, head[id][u]};
  head[id][u] = tot++;
}
void dfs(int u) {
  while (u <= n && vis[u]) u++;
  if (u == n + 1) return;
  used[u] = vis[u] = true;
  for (int i = head[0][u]; ~i; i = edge[i].nex) {
    v = edge[i].to;
    vis[v] = true;
  }
  dfs(u + 1);
  for (int i = head[1][u]; ~i; i = edge[i].nex) {
    v = edge[i].to;
    if (used[v]) {
      used[u] = false;
      break;
    }
  }
}
int main(void) {
  if (fopen("in", "r") != NULL) {
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  }
  while (~scanf("%d%d", &n, &m)) {
    init();
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      addedge(u, v, 0);
      addedge(v, u, 1);
    }
    dfs(1);
    vector<int> ans;
    for (int i = 1; i <= n; i++)
      if (used[i]) ans.push_back(i);
    printf("%d\n", (int)ans.size());
    for (int i = 0; i < ans.size(); i++)
      printf("%d%c", ans[i], " \n"[ans.size() - 1 == i]);
  }
  return 0;
}
