#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
vector<int> w[MAXN];
int st[MAXN], stot = 0;
int n, m;
int vis[MAXN];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    w[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      for (int j = 0; j < int(w[i].size()); j++) {
        vis[w[i][j]] = 1;
      }
      st[++stot] = i;
    }
  }
  memset(vis, 0, sizeof(vis));
  int ans = 0;
  while (stot > 0) {
    int k = st[stot];
    stot--;
    if (vis[k]) continue;
    ans++;
    int key = 0;
    for (int i = 0; i < int(w[k].size()); i++)
      if (vis[w[k][i]] == 2) key = 1;
    if (key) continue;
    vis[k] = 2;
    for (int i = 0; i < int(w[k].size()); i++) vis[w[k][i]] = 1;
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++)
    if (vis[i] == 2) printf("%d ", i);
}
