#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int m, n, cnt, head[N], pre[N], to[N];
vector<int> gg[N];
inline void addedge(int u, int v) {
  pre[++cnt] = head[u];
  head[u] = cnt;
  to[cnt] = v;
}
bool vis[N], hav[N];
void dfs(int now) {
  if (now == n + 1) return;
  int i;
  for (i = now; i <= n; i++)
    if (!vis[i]) break;
  if (i == n + 1) return;
  vis[i] = 1;
  int sz = gg[i].size();
  for (int j = head[i]; j; j = pre[j]) vis[to[j]] = 1;
  dfs(i + 1);
  for (int j = 0; j < sz; j++)
    if (hav[gg[i][j]]) return;
  hav[i] = 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
    gg[y].push_back(x);
  }
  dfs(1);
  cnt = 0;
  for (int i = 1; i <= n; i++) cnt += hav[i];
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (hav[i]) printf("%d ", i);
  printf("\n");
  return 0;
}
