#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 10;
int n, m, a, b, used[N];
vector<int> ans1, ans;
vector<int> v[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
  }
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      used[i] = 1;
      ans1.push_back(i);
      for (int j = 0; j < (int)v[i].size(); ++j) {
        used[v[i][j]] = 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    used[i] = 0;
  }
  for (int i = ans1.size() - 1; i >= 0; --i) {
    if (!used[ans1[i]]) {
      used[ans1[i]] = 1;
      ans.push_back(ans1[i]);
      for (int j = 0; j < (int)v[ans1[i]].size(); ++j) {
        used[v[ans1[i]][j]] = 1;
      }
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
