#include <bits/stdc++.h>
using namespace std;
inline int getidx(const vector<int>& ar, int x) {
  return lower_bound(ar.begin(), ar.end(), x) - ar.begin();
}
inline long long GCD(long long a, long long b) {
  long long n;
  if (a < b) swap(a, b);
  while (b != 0) {
    n = a % b;
    a = b;
    b = n;
  }
  return a;
}
inline long long LCM(long long a, long long b) {
  if (a == 0 || b == 0) return GCD(a, b);
  return a / GCD(a, b) * b;
}
inline long long CEIL(long long n, long long d) {
  return n / d + (long long)(n % d != 0);
}
inline long long ROUND(long long n, long long d) {
  return n / d + (long long)((n % d) * 2 >= d);
}
inline long long POW(long long a, long long n) {
  if (n < 0) return 0;
  long long ret = 1;
  while (n) {
    if (n % 2) ret *= a;
    a = a * a;
    n /= 2;
  }
  return ret;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  int cnt = 0;
  for (auto vv : v) {
    os << vv;
    if (++cnt < v.size()) os << ",";
  }
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> v) {
  os << "[";
  int cnt = 0;
  for (auto vv : v) {
    os << vv;
    if (++cnt < v.size()) os << ",";
  }
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
  return os << "(" << p.first << "," << p.second << ")";
}
const int MAXN = 1e6;
int n, m, vis[MAXN];
vector<int> sav, ans, g[MAXN];
void input() {
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
  }
}
int solve() {
  for (int(i) = (0); (i) < (int)(n); ++(i)) {
    if (!vis[i]) {
      sav.push_back(i);
      vis[i] = 1;
      for (auto& v : g[i]) vis[v] = 1;
    }
  }
  memset(vis, 0, sizeof(vis));
  for (int(i) = ((int)(sav).size() - 1); (i) >= (int)(0); --(i)) {
    int u = sav[i];
    if (!vis[u]) {
      ans.push_back(u);
      vis[u] = 1;
      for (auto& v : g[u]) vis[v] = 1;
    }
  }
  cout << ans.size() << '\n';
  for (int(i) = (0); (i) < (int)(ans.size()); ++(i)) cout << ans[i] + 1 << ' ';
  cout << '\n';
  return 0;
}
void execute() { input(), solve(); }
int main(void) {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  execute();
  return 0;
}
