#include <bits/stdc++.h>
using namespace std;
const int N = 1000050;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end() {}
int n, m, vis[N], choose[N];
vector<int> e[N];
int a[N];
inline void solve() {
  scanf("%d%d", &n, &m);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) a[i] = i;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
  }
  do {
    memset(vis, 0, sizeof(vis)), memset(choose, 0, sizeof(choose));
    random_shuffle(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i) {
      if (vis[a[i]]) continue;
      vis[a[i]] = choose[a[i]] = 1;
      for (auto v : e[a[i]]) vis[v] = true;
    }
    for (int i = n; i; --i) {
      if (choose[a[i]]) {
        for (auto v : e[a[i]]) choose[v] = 0;
      }
    }
  } while ((++cnt) < 5);
  vector<int> ans;
  for (int i = 1; i <= n; ++i)
    if (choose[a[i]]) ans.push_back(a[i]);
  cout << ans.size() << endl;
  for (auto i : ans) cout << i << ' ';
}
int main() {
  TIME__START = clock();
  int Test = 1;
  while (Test--) {
    solve();
  }
  TIME__END = clock();
  program_end();
  return 0;
}
