#include <bits/stdc++.h>
using namespace std;
bool bit(int n, int i) { return (n >> i) & 1; }
int ceil(int a, int b) { return ceil(((long double)a) / b); }
int faltu;
const int mod = 1e9 + 7;
const long long inf = 4e18;
const long long ninf = -inf;
const int imax = 2e9 + 100;
const int maxn = 1e6 + 100;
int n, m;
vector<int> g[maxn];
vector<int> save;
bool mark[maxn], mark1[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  ;
  time_t t1, t2;
  t1 = clock();
  srand(time(0));
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) {
      mark[i] = true;
      save.push_back(i);
      for (int j : g[i]) {
        mark[j] = true;
      }
    }
  }
  reverse(save.begin(), save.end());
  vector<int> ans;
  for (int i : save) {
    if (!mark1[i]) {
      ans.push_back(i);
      for (int j : g[i]) {
        mark1[j] = true;
      }
    }
  }
  cout << ans.size() << endl;
  for (int i : ans) {
    cout << i << ' ';
  }
  t2 = clock();
  cerr << "time taken: " << t2 - t1 << endl;
  return 0;
}
