#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const long long INFF = (long long)1e18;
const int mod = (int)1e9 + 7;
const int MXN = (int)1e6 + 7;
vector<int> edge[MXN], re_edge[MXN];
int ans[MXN];
set<int> st;
void go() {
  if (st.empty()) return;
  int v = *st.begin();
  for (int u : edge[v]) {
    st.erase(u);
  }
  st.erase(v);
  go();
  bool die = 0;
  for (int u : re_edge[v]) {
    if (ans[u] == 1) die = 1;
  }
  if (!die) ans[v] = 1;
  return;
}
int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i < m + 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    edge[u].push_back(v);
    re_edge[v].push_back(u);
  }
  for (int i = 1; i < n + 1; i++) st.insert(i);
  go();
  int num = 0;
  for (int i = 1; i < n + 1; i++)
    if (ans[i]) num++;
  printf("%d\n", num);
  for (int i = 1; i < n + 1; i++)
    if (ans[i]) printf("%d ", i);
  puts("");
  return 0;
}
