#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;
vector<int> G[MAX_N], rG[MAX_N];
bool used[MAX_N], alive[MAX_N];
int n, m;
vector<int> ans;
void dfs(int u) {
  if (u == n) return;
  if (!alive[u]) return dfs(u + 1);
  alive[u] = false;
  for (auto&(v) : (G[u])) {
    alive[v] = false;
  }
  dfs(u + 1);
  bool flag = true;
  for (auto&(v) : (rG[u])) {
    flag &= (!used[v]);
  }
  if (flag) {
    used[u] = true;
    ans.push_back(u);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < (int)(m); ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b), rG[b].push_back(a);
  }
  for (int i = 0; i < (int)(n); ++i) {
    alive[i] = true;
  }
  dfs(0);
  cout << (int)(ans).size() << "\n";
  for (int i = 0; i < (int)((int)(ans).size() - 1); ++i) {
    cout << ans[i] + 1 << " ";
  }
  cout << ans.back() + 1 << "\n";
  return 0;
}
