#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
set<int> st;
set<int>::iterator it;
int n, m, used[N], hmm[N];
vector<int> graph[N], vec, b[N];
void lmao() {
  if (st.size() == 0) {
    return;
  }
  it = st.begin();
  int u = *it;
  for (int i = 0; i < graph[u].size(); i++) {
    int v = graph[u][i];
    st.erase(v);
  }
  st.erase(u);
  lmao();
  for (int i = 0; i < b[u].size(); i++) {
    int v = b[u][i];
    if (hmm[v]) return;
  }
  hmm[u] = 1;
  vec.push_back(u);
}
int main() {
  cin.tie(0), ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) st.insert(i);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    b[v].push_back(u);
  }
  lmao();
  cout << vec.size() << "\n";
  for (int i = 0; i < vec.size(); i++) cout << vec[i] << " ";
}
