#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class A, class B, class C>
struct Triple {
  A first;
  B second;
  C third;
  bool operator<(const Triple& t) const {
    if (first != t.first) return first < t.first;
    if (second != t.second) return second < t.second;
    return third < t.third;
  }
};
template <class T>
void ResizeVec(T&, vector<long long>) {}
template <class T>
void ResizeVec(vector<T>& vec, vector<long long> sz) {
  vec.resize(sz[0]);
  sz.erase(sz.begin());
  if (sz.empty()) {
    return;
  }
  for (T& v : vec) {
    ResizeVec(v, sz);
  }
}
template <class A, class B, class C>
ostream& operator<<(ostream& out, Triple<A, B, C> t) {
  return out << "(" << t.first << ", " << t.second << ", " << t.third << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
template <class T>
ostream& operator<<(ostream& out, set<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
template <class L, class R>
ostream& operator<<(ostream& out, map<L, R> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  if (0) cout << fixed << setprecision(10);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > slo(n + 2);
  vector<long long> indeg(n + 2);
  vector<vector<long long> > trans(n + 2);
  for (long long i = (1); i <= (m); ++i) {
    long long a, b;
    cin >> a >> b;
    slo[a].push_back(b);
    trans[b].push_back(a);
    indeg[b]++;
  }
  vector<long long> used(n + 2);
  for (long long i = (1); i <= (n); ++i) {
    long long any_nei = 0;
    for (auto nei : slo[i]) {
      if (used[nei]) {
        any_nei = 1;
      }
    }
    for (auto nei : trans[i]) {
      if (used[nei]) {
        any_nei = 1;
      }
    }
    if (!any_nei) {
      used[i] = 1;
    }
  }
  while (1) {
    vector<long long> has_me_or_pred(n + 2);
    vector<long long> is_fine(n + 2);
    vector<long long> ord(n + 2);
    iota((ord).begin(), (ord).end(), 1);
    for (long long ii = (1); ii <= (n); ++ii) {
      long long i = ord[ii - 1];
      if (used[i]) {
        has_me_or_pred[i] = 1;
      } else {
        for (auto nei : trans[i]) {
          if (used[nei]) {
            has_me_or_pred[i] = 1;
          }
        }
      }
    }
    for (long long ii = (1); ii <= (n); ++ii) {
      long long i = ord[ii - 1];
      if (has_me_or_pred[i]) {
        is_fine[i] = 1;
        for (auto nei : slo[i]) {
          is_fine[nei] = 1;
        }
      }
    }
    long long all_fine = 1;
    for (long long ii = (1); ii <= (n); ++ii) {
      long long i = ord[ii - 1];
      if (!is_fine[i]) {
        all_fine = 0;
        long long skip = 0;
        for (auto nei : trans[i]) {
          if (used[nei]) {
            skip = 1;
          }
        }
        if (!skip) {
          for (auto nei : slo[i]) {
            used[nei] = 0;
          }
          used[i] = 1;
        }
      }
    }
    if (all_fine) {
      long long k = 0;
      for (long long i = (1); i <= (n); ++i) {
        if (used[i]) {
          k++;
        }
      }
      cout << k << endl;
      for (long long i = (1); i <= (n); ++i) {
        if (used[i]) {
          cout << i << " ";
        }
      }
      cout << endl;
      return 0;
    }
  }
  return 0;
}
