#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
vector<int> g[N];
vector<int> r[N];
int n, m;
int to[N], vis[N], q[N];
int32_t main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < (m + 1); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    r[y].push_back(x);
  }
  for (int i = 1; i < (n + 1); ++i) {
    if (vis[i]) continue;
    if (!vis[i]) {
      to[i] = 1;
      vis[i] = 1;
      for (auto w : g[i]) {
        vis[w] = 1;
      }
    }
  }
  vector<int> ans;
  for (int j = n; j >= 1; j--) {
    if (!to[j]) continue;
    bool is = false;
    for (auto w : r[j]) {
      is |= q[w];
    }
    q[j] = is ^ 1;
    if (is ^ 1) {
      ans.push_back(j);
    }
  }
  printf("%d\n", (int)(ans).size());
  for (auto& w : ans) {
    printf("%d ", w);
  }
}
