#include <bits/stdc++.h>
const int maxn = 1e6 + 6;
using namespace std;
int n, m, tot, head[maxn], vis[maxn], ans[maxn], anscnt;
struct Edge {
  int To, Next;
} ed[maxn * 2];
void addedge(int u, int v) {
  ed[++tot].To = v;
  ed[tot].Next = head[u];
  head[u] = tot;
}
int main() {
  cin >> n >> m;
  int a, b;
  for (int i = 1; i <= m; i++) scanf("%d%d", &a, &b), addedge(a, b);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = -2;
      for (int j = head[i]; j; j = ed[j].Next) {
        int v = ed[j].To;
        vis[v] = min(vis[v], -1);
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    if (vis[i] == -2) {
      ans[++anscnt] = i;
      for (int j = head[i]; j; j = ed[j].Next) {
        int v = ed[j].To;
        vis[v] = -1;
      }
    }
  }
  cout << anscnt << endl;
  for (int i = anscnt; i >= 1; i--) {
    printf("%d ", ans[i]);
  }
  puts("");
  return 0;
}
