#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
inline void cmin(int &x, int y) {
  if (y < x) x = y;
}
inline void cmax(int &x, int y) {
  if (y > x) x = y;
}
const int MAXN = 1e6 + 5;
vector<int> adj[2][MAXN];
int del[MAXN];
bool picked[MAXN];
int n, m, cur = 0;
void go() {
  while (cur < n && del[cur]) cur++;
  if (cur == n) return;
  int v = cur++;
  del[v]++;
  picked[v] = true;
  for (int x : adj[0][v]) del[x]++;
  go();
  for (int x : adj[1][v])
    if (picked[x]) {
      picked[v] = false;
      break;
    }
}
int main() {
  cin >> n >> m;
  int x, y;
  while (m--) {
    scanf("%d %d", &x, &y);
    --x;
    --y;
    adj[0][x].push_back(y);
    adj[1][y].push_back(x);
  }
  go();
  int c = 0;
  for (int i = 0; i < n; i++)
    if (picked[i]) c++;
  cout << c << "\n";
  for (int i = 0; i < n; i++)
    if (picked[i]) printf("%d ", i + 1);
  return 0;
}
