#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAX = 1e6 + 10;
int N, M;
vector<int> adj[MAX], rev[MAX];
bool used[MAX], met[MAX];
void solve(int node) {
  for (int i = node; i <= N; i++) {
    if (met[i]) continue;
    met[i] = true;
    for (int a : adj[i]) {
      met[a] = true;
    }
    solve(i + 1);
    bool need = true;
    for (int a : rev[i]) {
      if (used[a]) {
        need = false;
      }
    }
    used[i] = need;
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    rev[b].push_back(a);
  }
  solve(1);
  int ans = 0;
  for (int i = 1; i <= N; i++) ans += used[i];
  cout << ans << "\n";
  for (int i = 1; i <= N; i++) {
    if (used[i]) {
      cout << i << " ";
    }
  }
  cout << "\n";
  return 0;
}
