#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int n, m;
int vis[maxn], used[maxn];
struct node {
  int u, v;
  node() {}
  node(int uu, int vv) : u(uu), v(vv) {}
};
node edge[maxn];
vector<int> G[maxn];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &edge[i].u, &edge[i].v);
    G[edge[i].u].push_back(edge[i].v);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    vis[i] = 1;
    for (int j = 0; j < G[i].size(); j++) {
      if (!vis[G[i][j]]) vis[G[i][j]] = 1;
    }
    used[i] = 1;
  }
  for (int i = n; i >= 1; i--) {
    if (used[i]) {
      for (int j = 0; j < G[i].size(); j++) {
        used[G[i][j]] = 0;
      }
    }
  }
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    if (used[i]) v.push_back(i);
  }
  printf("%d\n", v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%d%c", v[i], i == v.size() - 1 ? '\n' : ' ');
  }
  return 0;
}
