#include <bits/stdc++.h>
using namespace std;
struct node {
  vector<int> son;
  vector<int> fa;
} arr[1000010];
int n, m;
int vis[1000010], mark[1000010];
vector<int> ans;
void Run() {
  while (scanf("%d%d", &n, &m) != EOF) {
    ans.clear();
    for (int i = 1, u, v; i <= m; ++i) {
      scanf("%d%d", &u, &v);
      arr[u].son.push_back(v);
      arr[v].fa.push_back(u);
    }
    memset(vis, 0, sizeof vis);
    memset(mark, 0, sizeof mark);
    for (int i = 1; i <= n; ++i) {
      if (!vis[i]) {
        vis[i] = 1;
        mark[i] = 1;
        for (auto v : arr[i].son) vis[v] = 1;
      }
    }
    for (int i = n; i >= 1; --i) {
      if (mark[i]) {
        for (auto v : arr[i].fa)
          if (mark[v]) {
            mark[i] = 0;
            break;
          }
        if (mark[i]) ans.push_back(i);
      }
    }
    printf("%d\n", ans.size());
    for (auto it : ans) printf("%d ", it);
    puts("");
  }
}
int main() {
  Run();
  return 0;
}
