#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, x, y, ans, v[1000010], mp[1000010];
vector<int> zh[1000010];
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 (!mp[i]) {
      v[i] = mp[i] = 1;
      for (j = 0; j < zh[i].size(); j++) {
        x = zh[i][j];
        mp[x] = 1;
      }
    }
  for (i = n; i; i--)
    if (v[i]) {
      for (j = 0; j < zh[i].size(); j++) {
        x = zh[i][j];
        v[x] = 0;
      }
    }
  for (i = 1; i <= n; i++)
    if (v[i]) ans++;
  printf("%d\n", ans);
  for (i = 1; i <= n; i++)
    if (v[i]) printf("%d ", i);
}
