#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> adjlist[1000050], ans;
bool done[1000050], use[1000050];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    adjlist[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if (!done[i]) {
      use[i] = true;
      for (auto j : adjlist[i]) done[j] = true;
    }
  }
  memset(done, false, sizeof done);
  for (int i = n; i >= 1; i--) {
    if (use[i] and !done[i]) {
      ans.push_back(i);
      done[i] = true;
      for (auto j : adjlist[i]) done[j] = true;
    }
  }
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i << " ";
}
