#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:210886422")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-11;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
long long nextLong(long long l, long long r) {
  uniform_int_distribution<long long> foo(l, r);
  return foo(rnd);
}
double nextDouble(double l, double r) {
  uniform_real_distribution<double> foo(l, r);
  return foo(rnd);
}
double workTime() { return double(clock()) / CLOCKS_PER_SEC; }
void myReturn(int code = 0) { exit(code); }
int n, m;
vector<int> G[1000010];
char st[1000010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) {
    if (st[i] == 0) {
      st[i] = 1;
      for (auto to : G[i]) {
        if (st[to] == 0) {
          st[to] = 2;
        }
      }
    }
  }
  vector<int> ans;
  for (int i = n; i >= 1; --i) {
    if (st[i] == 1) {
      ans.push_back(i);
      for (auto to : G[i]) {
        st[to] = 2;
      }
    }
  }
  reverse(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (auto i : ans) {
    printf("%d ", i);
  }
  myReturn();
}
