#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
vector<int> G[maxn];
int n, m;
int vis[maxn], chose[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = 1;
      chose[i] = 1;
      for (int j = 0; j < G[i].size(); j++) {
        int v = G[i][j];
        vis[v] = 1;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (chose[i]) {
      for (int j = 0; j < G[i].size(); j++) {
        int v = G[i][j];
        chose[v] = 0;
      }
    }
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (chose[i]) ans.push_back(i);
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
