#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int numNodes, numEdges;
  cin >> numNodes >> numEdges;
  vector<vector<int>> graph(numNodes);
  for (int i = 0; i != numEdges; ++i) {
    int from, to;
    cin >> from >> to;
    graph[--from].push_back(--to);
  }
  vector<bool> removedNodes(graph.size(), false);
  vector<int> saves;
  for (int node = 0; node != graph.size(); ++node) {
    if (!removedNodes[node]) {
      removedNodes[node] = true;
      for (int neighbor : graph[node])
        if (!removedNodes[neighbor]) removedNodes[neighbor] = true;
      saves.push_back(node);
    }
  }
  set<int> solution;
  vector<bool> reachable(graph.size(), false);
  for (int i = saves.size() - 1; i >= 0; --i) {
    int leader = saves[i];
    if (!reachable[leader]) {
      solution.insert(leader);
      for (int neighbor : graph[leader]) reachable[neighbor] = true;
    }
  }
  cout << solution.size() << "\n";
  bool firstElement = true;
  for (int node : solution) {
    if (firstElement) {
      firstElement = false;
    } else {
      cout << " ";
    }
    cout << node + 1;
  }
  cout << "\n";
}
