#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
vector<int> v[N];
int vis[N], ans[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int s, t;
    scanf("%d%d", &s, &t);
    v[s].push_back(t);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      vis[i] = 1;
      for (int j = 0; j < v[i].size(); j++) {
        if (vis[v[i][j]] == 0) vis[v[i][j]] = -1;
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (vis[i] == 1) {
      for (int j = 0; j < v[i].size(); j++) {
        vis[v[i][j]] = -1;
      }
    }
  }
  int ans_len = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 1) {
      ans[ans_len++] = i;
    }
  }
  printf("%d\n", ans_len);
  for (int i = 0; i < ans_len; i++) {
    printf("%d", ans[i]);
    if (i == ans_len - 1)
      printf("\n");
    else
      printf(" ");
  }
  return 0;
}
