#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = 3.1415926535;
const int inf = 5e8;
const int maxn = 1e5 + 7;
const long long int mod = 1e9 + 7;
vector<int> graf[1000007];
vector<int> ata[1000007];
bool vis[1000007];
bool in[1000007];
set<int> node;
int n, m;
vector<int> al;
void solve() {
  int x = *node.begin();
  node.erase(node.begin());
  vector<int> yedek;
  for (int y : graf[x]) {
    int g = node.erase(y);
    if (g) yedek.push_back(y);
  }
  if (((int)node.size())) solve();
  bool ok = false;
  for (int y : ata[x]) {
    if (in[y]) {
      ok = true;
    }
  }
  if (!ok) {
    in[x] = true;
    al.push_back(x);
  }
  for (int y : yedek) node.insert(y);
}
int main() {
  scanf("%d %d", &n, &m);
  int i;
  for (i = 1; i <= n; i++) node.insert(i);
  int x, y;
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    ata[y].push_back(x);
    graf[x].push_back(y);
  }
  solve();
  printf("%d\n", ((int)al.size()));
  for (int xx : al) printf("%d ", xx);
  puts("");
  return 0;
}
