#include <bits/stdc++.h>
using namespace std;
vector<int> a[1000100], b[1000100], ans;
stack<int> st;
int n, m;
bool del[1000100], used[1001000];
int main() {
  scanf("%d%d", &n, &m);
  int i;
  for (i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    b[v].push_back(u);
  }
  memset(del, 0, sizeof(del));
  for (i = 1; i <= n; i++) {
    if (del[i]) continue;
    del[i] = 1;
    st.push(i);
    int len = a[i].size(), j;
    for (j = 0; j < len; j++) del[a[i][j]] = 1;
  }
  memset(used, 0, sizeof(used));
  while (!st.empty()) {
    int u = st.top();
    st.pop();
    used[u] = 1;
    int j, len = b[u].size();
    for (j = 0; j < len; j++)
      if (used[b[u][j]]) {
        used[u] = 0;
        break;
      }
    if (used[u]) ans.push_back(u);
  }
  int len = ans.size();
  printf("%d\n", ans.size());
  for (i = 0; i < len; i++) printf("%d ", ans[i]);
  return 0;
}
