#include <bits/stdc++.h>
using namespace std;
int n, m, res;
vector<vector<int> > child(1000001), parent(1000001);
bool vis[1000001], selected[1000001];
void dfs(int x) {
  vis[x] = true;
  for (int i = 0; i < child[x].size(); i++) {
    vis[child[x][i]] = true;
  }
  for (int i = 0; i < parent[x].size(); i++) {
    if (!vis[parent[x][i]]) {
      dfs(parent[x][i]);
    }
  }
  if (parent[x].size() == 0) {
    selected[x] = true;
    res++;
  } else {
    bool select = true;
    for (int i = 0; i < parent[x].size(); i++) {
      if (selected[parent[x][i]]) {
        select = false;
      }
    }
    selected[x] = select;
    if (select) res++;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    child[a].push_back(b);
    parent[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
  }
  cout << res << endl;
  for (int i = 1; i <= n; i++) {
    if (selected[i]) printf("%d ", i);
  }
  cout << endl;
  return 0;
}
