#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000000;
vector<int> adjMat[maxN];
vector<int> saved;
vector<bool> marked(maxN, false);
vector<int> ans;
vector<bool> reachable(maxN, false);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adjMat[a].push_back(b);
  }
  for (int i = 0; i < n; i++) {
    if (!marked[i]) {
      marked[i] = true;
      saved.push_back(i);
      for (int j = 0; j < (int)adjMat[i].size(); j++) {
        marked[adjMat[i][j]] = true;
      }
    }
  }
  for (int i = (int)saved.size() - 1; i >= 0; i--) {
    if (ans.size() == 0 || !reachable[saved[i]]) {
      ans.push_back(saved[i]);
      for (int j = 0; j < (int)adjMat[saved[i]].size(); j++)
        reachable[adjMat[saved[i]][j]] = true;
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < (int)ans.size(); i++) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
