#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7FFFFFFF;
const long long LINF = 0x7FFFFFFFFFFFFF;
void guan() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int maxn = 1010101;
const int mod = 1e9 + 7;
const double eps = 1e-12;
vector<int> g[maxn];
int vis[maxn];
set<int> ans;
int main() {
  guan();
  int T, Case = 0;
  long long m, l, k, b, n;
  while (cin >> n >> m) {
    for (auto i = (1); i <= (n); ++i) g[i].clear();
    memset(vis, 0, sizeof(vis));
    ans.clear();
    for (auto i = (1); i <= (m); ++i) {
      int u, v;
      cin >> u >> v;
      g[u].push_back(v);
    }
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) {
        vis[i] = 1;
        ans.insert(i);
        for (auto v : g[i]) {
          vis[v] = 1;
        }
      }
    }
    for (int i = n; i >= 1; i--) {
      if (ans.find(i) != ans.end()) {
        for (auto v : g[i]) {
          if (ans.find(v) != ans.end()) {
            ans.erase(ans.find(v));
          }
        }
      }
    }
    cout << ans.size() << endl;
    for (auto e : ans) cout << e << " ";
    cout << endl;
  }
  return 0;
}
