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