#include <bits/stdc++.h>
using namespace std;
int n, m, a, b, ret;
vector<int> adj[10004], v;

int go(int here){
    int cnt = 0;
    for(int there : adj[here]){
        cnt += go(there);
        cnt++;
    }
    return cnt;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        adj[b].push_back(a);
    }
    for(int i = 0; i < m; i++){
        ret = max(ret, go(i));
    }
    for(int i = 0; i < m; i++){
        if(ret == go(i)) v.push_back(i);
    }

    for(int c : v) cout << c << ' ';
}