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