#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, m;
vector<int> e[N];
bool sel[N], vis[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  int t1, t2;
  for (int i = 1; i <= m; i++) {
    cin >> t1 >> t2;
    e[t1].push_back(t2);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      sel[i] = 1;
      for (auto &j : e[i]) vis[j] = 1;
    }
  for (int i = n; i > 0; --i)
    if (sel[i])
      for (auto &j : e[i]) sel[j] = 0;
  vector<int> ans;
  for (int i = 1; i <= n; i++)
    if (sel[i]) ans.push_back(i);
  cout << ans.size() << endl;
  for (auto &i : ans) cout << i << ' ';
  return 0;
}
