#include <bits/stdc++.h>
using namespace std;
bool dd[1000005];
vector<int> a[1000005], ans;
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
  }
  for (int i = (1); i <= (n); ++i)
    if (!dd[i])
      for (int v : a[i])
        if (v > i) dd[v] = 1;
  for (int i = (n); i >= (1); --i)
    if (!dd[i]) {
      ans.push_back(i);
      for (int v : a[i]) dd[v] = 1;
    }
  cout << ans.size() << '\n';
  for (int v : ans) cout << v << ' ';
}
