#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (T e : v) {
    os << e << ' ';
  }
  return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> edges[n];
  vector<int> reverse_edges[n];
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    edges[a - 1].emplace_back(b - 1);
    reverse_edges[b - 1].emplace_back(a - 1);
  }
  vector<int> vertices;
  vector<bool> counted(n);
  for (int i = 0; i < n; ++i) {
    if (counted[i]) {
      continue;
    }
    counted[i] = true;
    vertices.emplace_back(i);
    for (auto v : edges[i]) {
      counted[v] = true;
    }
  }
  fill(counted.begin(), counted.end(), false);
  unordered_set<int> ans;
  for (int i = vertices.size() - 1; i >= 0; --i) {
    bool found = false;
    for (auto v : reverse_edges[vertices[i]]) {
      if (ans.count(v)) {
        found = true;
        break;
      }
    }
    if (!found) {
      ans.emplace(vertices[i]);
    }
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x + 1 << ' ';
  }
  cout << endl;
  return 0;
}
