#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e18;
const int N = 1e6 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
void chkmax(T &a, T b) {
  a < b ? a = b : 0;
};
template <typename T>
void chkmin(T &a, T b) {
  a > b ? a = b : 0;
};
int n, m;
vector<int> E[N];
bool vis[N], use[N];
int main() {
  cin >> n >> m;
  for (int i = 1, u, v; i <= m; i++) u = gi(), v = gi(), E[u].push_back(v);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      vis[i] = use[i] = 1;
      for (int j : E[i]) vis[j] = 1;
    }
  for (int i = n; i; i--)
    if (use[i])
      for (int j : E[i]) use[j] = 0;
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (use[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (use[i]) printf("%d ", i);
  return 0;
}
