#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long, long long> > > adj(1000005);
int rem[1000005], vis[1000005];
int main() {
  int n, m;
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d", &a);
    ;
    scanf("%d", &b);
    ;
    a--;
    b--;
    adj[a].push_back({b, 1});
    adj[b].push_back({a, 0});
  }
  vector<int> vt;
  for (int i = 0; i < n; i++) {
    if (rem[i]) continue;
    for (auto e : adj[i]) {
      if (e.second == 1) {
        rem[e.first] = 1;
      }
    }
    vt.push_back(i);
  }
  reverse(vt.begin(), vt.end());
  vector<int> ans;
  for (auto e : vt) {
    bool ok = 1;
    for (auto p : adj[e]) {
      if (vis[p.first] && p.second == 0) ok = 0;
    }
    if (ok) {
      ans.push_back(e);
      vis[e] = 1;
    }
  }
  printf("%d\n", ans.size());
  for (auto e : ans) printf("%d ", e + 1);
  ;
}
