#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> edge[1000006];
vector<int> ans;
int vis[1000006];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      for (int j = 0; j < (int)((edge[i]).size()); j++)
        if (edge[i][j] > i) vis[edge[i][j]] = 1;
    }
  }
  for (int i = n; i >= 1; i--) {
    if (!vis[i]) {
      for (int j = 0; j < (int)((edge[i]).size()); j++) vis[edge[i][j]] = 1;
    }
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) ans.push_back(i);
  printf("%d\n", (int)((ans).size()));
  for (int i = 0; i < (int)((ans).size()); i++)
    printf("%d%c", ans[i], i == (int)((ans).size()) - 1 ? '\n' : ' ');
  return 0;
}
