#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
const int apsz = 26;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
const int maxm = maxn + 10;
vector<int> edge[maxn];
int n, m;
int deleted[maxn];
int saved[maxn];
int reached[maxn];
int main(void) {
  scanf("%d", &(n)), scanf("%d", &(m));
  for (int i = (0); i < (m); ++i) {
    int u, v;
    scanf("%d", &(u)), scanf("%d", &(v)), u--, v--;
    edge[u].push_back(v);
  }
  for (int i = (0); i < (n); ++i) {
    if (deleted[i]) continue;
    deleted[i] = 1;
    saved[i] = 1;
    for (auto v : edge[i]) deleted[v] = 1;
  }
  vector<int> ans;
  for (int i = (n - 1); i >= (0); --i) {
    if (!saved[i]) continue;
    if (!reached[i]) {
      ans.push_back(i + 1);
      for (auto v : edge[i]) reached[v] = 1;
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto v : ans) printf("%d ", v);
  puts("");
  return 0;
}
