#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
long long fac[1] = {1}, inv[1] = {1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
long long cmb(long long r, long long c) {
  return fac[r] * inv[c] % MOD * inv[r - c] % MOD;
}
vector<int> v[1000000], rv[1000000];
char visit[1000000], mark[1000000];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    v[a].push_back(b);
    rv[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (visit[i] == 0) {
      visit[i] = 1;
      mark[i] = 1;
      for (int j : v[i]) visit[j] = 1;
    }
  }
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (mark[i]) {
      for (int j : rv[i])
        if (mark[j]) mark[i] = 0;
      cnt += mark[i];
    }
  }
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++)
    if (mark[i]) printf("%d ", i + 1);
}
