#include <bits/stdc++.h>
using namespace std;
int n, m, cnt;
bool vis[1000005];
vector<int> G[1000005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
  }
  for (int u = 1; u <= n; u++) {
    if (vis[u]) continue;
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (v > u) vis[v] = true;
    }
  }
  for (int u = n; u > 0; u--) {
    if (vis[u]) continue;
    for (int i = 0; i < G[u].size(); i++) vis[G[u][i]] = true;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) printf("%d ", i);
}
