#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int maxn = 2e6 + 10;
vector<int> G[maxn];
bool vis[maxn];
bool chose[maxn];
int main() {
  int n, m, u, v;
  while (~scanf("%d%d", &n, &m)) {
    memset(vis, false, sizeof(vis));
    memset(chose, false, sizeof(chose));
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &u, &v);
      G[u].push_back(v);
    }
    for (int i = 1; i <= n; i++) {
      if (vis[i] == 0) {
        vis[i] = 1;
        int len = G[i].size();
        for (int j = 0; j <= len - 1; j++) {
          vis[G[i][j]] = true;
        }
        chose[i] = true;
        vis[i] = true;
      }
    }
    for (int i = n; i >= 1; i--) {
      if (chose[i] == true) {
        int len = G[i].size();
        for (int j = 0; j <= len - 1; j++) {
          chose[G[i][j]] = false;
        }
      }
    }
    vector<int> v;
    int len = 0;
    for (int i = 1; i <= n; i++) {
      if (chose[i] == 1) {
        v.push_back(i);
        len++;
      }
    }
    printf("%d\n", len);
    for (int i = 0; i < len; i++) {
      printf("%d", v[i]);
      if (i != len - 1) printf(" ");
    }
    puts("");
  }
  return 0;
}
