#include <bits/stdc++.h>
using namespace std;
int n, m;
int x, y, lenans = 0;
int vis[1000000 + 5], ans[1000000 + 5];
vector<int> v[1000000 + 5];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = 1;
      ans[i] = 1;
      if (!v[i].size()) continue;
      for (int j = 0; j < v[i].size(); j++) vis[v[i][j]] = 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (ans[i]) {
      lenans++;
      if (!v[i].size()) continue;
      for (int j = 0; j < v[i].size(); j++) ans[v[i][j]] = 0;
    }
  }
  printf("%d\n", lenans);
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", i);
  return 0;
}
