#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 5;
vector<int> adjList[N];
unordered_set<int> remaining;
vector<int> inQ(N, 0), nextToQ(N, 0);
vector<int> ans;
void solve(int u) {
  remaining.erase(u);
  for (auto v : adjList[u]) {
    remaining.erase(v);
  }
  if (!remaining.empty()) {
    solve(*remaining.begin());
  }
  if (!nextToQ[u]) {
    inQ[u] = 1;
    nextToQ[u] = 1;
    for (auto v : adjList[u]) {
      nextToQ[v] = 1;
    }
    ans.push_back(u);
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adjList[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    remaining.insert(i);
  }
  solve(1);
  printf("%d\n", (int)ans.size());
  for (auto u : ans) {
    printf("%d ", u);
  }
  puts("");
}
