#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 1001000;
void MOD(long long &a) {
  if (a >= mod) a -= mod;
}
void MOD(long long &a, long long c) {
  if (a >= c) a -= c;
}
void ADD(long long &a, long long b) {
  a += b;
  MOD(a);
}
void ADD(long long &a, long long b, long long c) {
  a += b;
  MOD(a, c);
}
long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return ans;
}
long long qpow(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c;
    b /= 2;
  }
  return ans;
}
int n, m;
vector<int> a[N], b[N], ans;
bool use[N], del[N];
void dfs(int x) {
  for (int i = x; i <= n; ++i) {
    if (!del[i]) {
      del[i] = 1;
      for (int j = 0; j < ((int)a[i].size()); j++) del[a[i][j]] = 1;
      dfs(i + 1);
      use[i] = 1;
      for (int j = 0; j < ((int)b[i].size()); j++)
        if (use[b[i][j]]) {
          use[i] = 0;
          break;
        }
      return;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    b[v].push_back(u);
  }
  dfs(1);
  for (int i = 1; i <= n; i++)
    if (use[i]) ans.push_back(i);
  printf("%d\n", ((int)ans.size()));
  for (int i = 0; i < ((int)ans.size()); i++) printf("%d ", ans[i]);
}
