#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int mod = 1000000007;
const double dancila = 3.14159265359;
const double eps = 1e-9;
int n, m;
vector<int> v[1000002], tr[1000002];
int cnt;
bool wa[1000002], tk[1000002];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    tr[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    if (!wa[i]) {
      tk[i] = 1;
      ++cnt;
      for (int j = 0; j < v[i].size(); ++j) {
        int vecin = v[i][j];
        wa[vecin] = 1;
      }
    }
  }
  for (int i = n; i >= 1; --i) {
    if (tk[i]) {
      for (int j = 0; j < tr[i].size(); ++j) {
        int vecin = tr[i][j];
        if (tk[vecin] && tk[i]) tk[i] = 0, --cnt;
      }
    }
  }
  cout << cnt << '\n';
  for (int i = 1; i <= n; ++i)
    if (tk[i]) cout << i << " ";
  return 0;
}
