#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const double oula = 0.57721566490153286060651209;
using namespace std;
vector<int> ve[1000005];
bool book[1000005];
bool used[1000005];
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    ve[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    if (!book[i]) {
      book[i] = 1;
      used[i] = 1;
      for (int j = 0; j < ve[i].size(); j++) {
        book[ve[i][j]] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = n; i; i--) {
    if (used[i]) {
      ans++;
      for (int j = 0; j < ve[i].size(); j++) {
        used[ve[i][j]] = 0;
      }
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; i++) {
    if (used[i]) {
      cout << i << " ";
    }
  }
}
