#include <bits/stdc++.h>
using namespace std;
vector<int> zh[1000001];
int n, m, x, y, i, j, ans, vis[1000001];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    zh[x].push_back(y);
  }
  for (i = 1; i <= n; i++)
    if (!vis[i]) {
      vis[i] = 1;
      for (j = 0; j < zh[i].size(); j++)
        if (!vis[zh[i][j]]) vis[zh[i][j]] = -1;
    }
  for (i = n; i; i--)
    if (vis[i] == 1) {
      for (j = 0; j < zh[i].size(); j++) vis[zh[i][j]] = -1;
    }
  for (i = 1; i <= n; i++)
    if (vis[i] == 1) ans++;
  printf("%d\n", ans);
  for (i = 1; i <= n; i++)
    if (vis[i] == 1) printf("%d ", i);
}
