#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
vector<int> e[N];
int vis[N], used[N];
int rd() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
void print(int x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
signed main() {
  int n, m;
  n = rd();
  m = rd();
  for (int i = 1; i <= m; ++i) {
    int u, v;
    u = rd();
    v = rd();
    e[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i)
    if (!used[i]) {
      vis[i] = 1;
      used[i] = 1;
      for (int v : e[i]) used[v] = 1;
    }
  for (int i = n; i >= 1; --i)
    if (vis[i]) {
      for (int v : e[i]) vis[v] = 0;
    }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans += vis[i];
  cout << ans << endl;
  for (int i = 1; i <= n; ++i)
    if (vis[i]) print(i), putchar(' ');
  return 0;
}
