#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
ifstream in_file("C:\\verseny\\minta\\be1.txt");
#define input in_file
#define INTHENAMEOFGOD
#else
#define input cin
#define INTHENAMEOFGOD \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#endif
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<ll, ll> pii;
ll N, M, a, b;
vvi G, Gi;
vb vis;
vi oda, vissza;
vi *vr;
ll dfs(ll x) {
ll ret = 1;
vis[x] = true;
for (ll next : G[x]) {
if (!vis[next]) {
ret += dfs(next);
} else {
(*vr)[x] += (*vr)[next];
}
}
(*vr)[x] += ret;
return ret;
}
int main() {
INTHENAMEOFGOD
input >> N >> M;
G.resize(N + 2);
Gi.resize(N + 2);
for (ll n = 0; n < M; n++) {
input >> a >> b;
a--; b--;
G[a].push_back(b);
Gi[b].push_back(a);
}
for (ll n = 0; n < N; n++) {
if (Gi[n].size() == 0) {
G[N].push_back(n);
Gi[n].push_back(N);
}
}
for (ll n = 0; n < N; n++) {
if (G[n].size() == 0) {
Gi[N+1].push_back(n);
G[n].push_back(N+1);
}
}
oda.assign(N + 2, 0);
vr = &oda;
vis.assign(N + 2, false);
dfs(N);
swap(G, Gi);
vissza.assign(N + 2, 0);
vr = &vissza;
vis.assign(N + 2, false);
dfs(N + 1);
vi ans;
for (ll n = 0; n < N + 2; n++) {
if (oda[n] + vissza[n] == N + 3) {
ans.push_back(n);
}
}
cout << ans.size() - 2 << "\n";
for (ll i : ans) {
if (i < N)
cout << i + 1 << " ";
}
}