#include <bits/stdc++.h>
using namespace std;
const int mod = (1e9) + 7;
const double eps = 1e-6;
const int siz = 1e6 + 5, siz2 = 1e5 + 5;
stack<int> av, cur;
bool del[siz], q[siz];
int n, m;
vector<int> to[siz], from[siz], ans;
void solve() {
  for (int i = 2; i <= n; i++) {
    av.push(i);
  }
  cur.push(1);
  del[1] = true;
  for (auto v : from[1]) {
    del[v] = true;
  }
  while (true) {
    while (!av.empty() && del[av.top()]) {
      av.pop();
    }
    if (av.empty()) {
      while (!cur.empty()) {
        int re_top = cur.top();
        cur.pop();
        bool need = true;
        for (auto v : to[re_top]) {
          if (q[v]) {
            need = false;
            break;
          }
        }
        if (need) {
          q[re_top] = true;
          ans.push_back(re_top);
        }
      }
      return;
    } else {
      int n_top = av.top();
      av.pop();
      cur.push(n_top);
      del[n_top] = true;
      for (auto v : from[n_top]) {
        del[v] = true;
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    from[a].push_back(b);
    to[b].push_back(a);
  }
  solve();
  int sz = ans.size();
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) {
    printf("%d", ans[i]);
    if (i < sz - 1) {
      printf(" ");
    } else {
      printf("\n");
    }
  }
  return 0;
}
