#include <bits/stdc++.h>
using namespace std;

const long long DIM = 100005;

int n, m , v1, v2, err;
int maxcurr[DIM];
vector<int> a[DIM];
vector< pair<int, int> > ans;

void dfs(int v, int curr){

    maxcurr[v] = 1;
    for(auto to : a[v]){
        if(maxcurr[to] == 0) dfs(to, curr+1);
        maxcurr[v] = max(maxcurr[v], maxcurr[to]+1);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

	cin >> n >> m;
    
    for(int i=1; i<=m; i++){
        cin >> v1 >> v2;
        a[v1].push_back(v2);
    }

    dfs(1, 0);

    for(int i=1; i<=n; i++){
            ans.push_back({maxcurr[i], i});
        }
    sort(ans.begin(), ans.end());
    reverse(ans.begin(), ans.end());

    for(auto x : a[ans[n-1].second]) if(x == 1) err = 1;

    cout << "NO" << endl;
    /*if(maxcurr[1] != n+1 || err == 0) cout << "NO";
    else{
        cout << "YES" << endl;        

        for(auto x : ans) cout << x.second << " ";
        cout << 1 << endl;

        //for(int i=1; i<=n; i++) cout << maxcurr[i] << " ";
    }*/
}
