//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
    {
        mark[v] = 0;
        return;
    }
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            break;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

ll invers[MAX_N];

ll n,m;
bool testgraph()
{
    fill(invers,invers+n+100,0);
    set<ll> noin;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
            invers[g[i][j]]++;
    }
    for(int i = 1;i<=n;++i)
    {
        if (invers[i] == 0)
            noin.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (noin.size() == 0)
            return true;
        int v = *noin.begin();
        noin.erase(noin.begin());
        for(int j = 0;j<g[v].size();++j)
        {
            invers[g[v][j]]--;
            if (invers[g[v][j]]==0)
                noin.insert(g[v][j]);
        }
        g[v].clear();
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    if (!testgraph())
        return cout << "YES",0;
    for(int i = n;i>=1;--i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        invers[u]--;
        g[v].erase(it);
        bool found = false;
        set<int> noin;
        if (invers[u] == 0)
            noin.insert(u);
        for(int j = 1;j<=n;++j)
        {
            if(noin.size() == 0)
            {
                found = true;
                break;
            }
            int f = *noin.begin();
            noin.erase(noin.begin());
            for(int k = 0;k<g[f].size();++k)
            {
                invers[g[f][k]]--;
                if (invers[g[f][k]] == 0)
                    noin.insert(g[f][k]);
            }
        }
        if (!found)
            return cout << "YES" << i,0;
        invers[u]++;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
    {
        mark[v] = 0;
        return;
    }
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            break;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

ll invers[MAX_N];

ll n,m;
bool testgraph()
{
    fill(invers,invers+n+100,0);
    set<ll> noin;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
            invers[g[i][j]]++;
    }
    for(int i = 1;i<=n;++i)
    {
        if (invers[i] == 0)
            noin.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (noin.size() == 0)
            return true;
        int v = *noin.begin();
        noin.erase(noin.begin());
        for(int j = 0;j<g[v].size();++j)
        {
            invers[g[v][j]]--;
            if (invers[g[v][j]]==0)
                noin.insert(g[v][j]);
        }
        g[v].clear();
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    if (!testgraph())
        return cout << "YES",0;
    for(int i = n;i>=1;--i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        invers[u]--;
        g[v].erase(it);
        bool found = false;
        set<int> noin;
        if (invers[u] == 0)
            noin.insert(u);
        for(int j = 1;j<=n;++j)
        {
            if(noin.size() == 0)
            {
                found = true;
                break;
            }
            int f = *noin.begin();
            noin.erase(noin.begin());
            for(int k = 0;k<g[f].size();++k)
            {
                invers[g[f][k]]--;
                if (invers[g[f][k]] == 0)
                    noin.insert(g[f][k]);
            }
        }
        if (!found)
            return cout << "YES",0;
        invers[u]++;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
    {
        mark[v] = 0;
        return;
    }
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            break;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

ll invers[MAX_N];

ll n,m;
bool hazf;
bool testgraph()
{
    fill(invers,invers+n+100,0);
    set<ll> noin;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
            invers[g[i][j]]++;
    }
    for(int i = 1;i<=n;++i)
    {
        if (invers[i] == 0)
            noin.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (noin.size() == 0)
            return true;
        int v = *noin.begin();
        noin.erase(noin.begin());
        for(int j = 0;j<g[v].size();++j)
        {
            invers[g[v][j]]--;
            if (invers[g[v][j]]==0)
                noin.insert(g[v][j]);
        }
        if (hazf)
        g[v].clear();
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    hazf = true;
    if (!testgraph())
        return cout << "YES",0;
    hazf = false;
    for(int i = 1;i<=n;++i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        g[v].erase(it);
        if (!testgraph())
            return cout << "YES",0;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
    {
        mark[v] = 0;
        return;
    }
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            break;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

ll invers[MAX_N];

ll n,m;

bool testgraph()
{
    fill(invers,invers+n+100,0);
    set<ll> noin;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
            invers[g[i][j]]++;
    }
    for(int i = 1;i<=n;++i)
    {
        if (!invers[i])
            noin.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (!noin.size())
            return true;
        int v = *noin.begin();
        noin.erase(noin.begin());
        for(int j = 0;j<g[v].size();++j)
        {
            invers[g[v][j]]--;
            if (!invers[g[v][j]])
                noin.insert(g[v][j]);
        }
        g[v].clear();
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    if (!testgraph())
        return cout << "YES",0;
    for(int i = 1;i<=n;++i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        g[v].erase(it);
        if (!testgraph())
            return cout << "YES",0;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
    {
        mark[v] = 0;
        return;
    }
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            break;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

ll invers[MAX_N];

ll n,m;

bool testgraph()
{
    fill(invers,invers+n+100,0);
    set<ll> noin;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
            invers[g[i][j]]++;
    }
    for(int i = 1;i<=n;++i)
    {
        if (!invers[i])
            noin.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (!noin.size())
            return true;
        int v = *noin.begin();
        noin.erase(noin.begin());
        for(int j = 0;j<g[v].size();++j)
        {
            invers[g[v][j]]--;
            if (!invers[g[v][j]])
                noin.insert(g[v][j]);
        }
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    for(int i = 1;i<=n;++i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    if (!found)
        return cout << "YES",0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        g[v].erase(it);
        if (!testgraph())
            return cout << "YES",0;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+5;
const ll MOD = 1e9+7;
using namespace std;

void yes()
{
    cout << "YES";
    exit(0);
}

void no()
{
    cout << "NO";
    exit(0);
}

vector<int> g[MAX_N];
int d[MAX_N];
int n,m;

bool check()
{
    memset(d , 0 ,sizeof d);
    for(int i = 1;i<=n;++i)
    {
        for(auto x:g[i])
        {
            if (!x)
                continue;
            d[x]++;
        }
    }
    vector<int> v;
    for(int i = 1;i<=n;++i)
    {
        if (!d[i])
            v.push_back(i);
    }
    for(int i = 0;i<v.size();++i)
    {
        int u = v[i];
        for(auto x:g[u])
        {
            if (!x)
                continue;
            d[x]--;
            if (!d[x])
                v.push_back(x);
        }
    }
    if (v.size()==n)
        return true;
    return false;
}

int main()
{
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
    }
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
        {
            int t = g[i][j];
            g[i][j] = 0;
            if (check())
                yes();
            g[i][j] = t;
        }
    }
    no();
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
    {
        mark[v] = 0;
        return;
    }
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            break;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

ll invers[MAX_N];

ll n,m;
bool hazf;
bool testgraph()
{
    fill(invers,invers+n+100,0);
    set<ll> noin;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<g[i].size();++j)
            invers[g[i][j]]++;
    }
    for(int i = 1;i<=n;++i)
    {
        if (invers[i] == 0)
            noin.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (noin.size() == 0)
            return true;
        int v = *noin.begin();
        noin.erase(noin.begin());
        for(int j = 0;j<g[v].size();++j)
        {
            invers[g[v][j]]--;
            if (invers[g[v][j]]==0)
                noin.insert(g[v][j]);
        }
        if (hazf)
        g[v].clear();
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    hazf = true;
    if (!testgraph())
        return cout << "YES",0;
    hazf = false;
    for(int i = n;i>=1;--i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        g[v].erase(it);
        if (!testgraph())
            return cout << "YES",0;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
        return;
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            return;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    ll n,m;
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    for(int i = 1;i<=n;++i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    for(int i = 1;i<=n;++i)
        mark[i]=0;
    if (!found)
        return cout << "YES",0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        g[v].erase(it);
        found = 0;
        for(int j = 1;j<=n;++j)
        {
            if (found)
                break;
            else
                dfs(j);
        }
        if (!found)
            return cout << "YES",0;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 1e5+5;
const ll MOD = 1e9+7;
using namespace std;

vector<int> g[510];
int mark[510];
int d[510];
int n,m,nw;

void yes()
{
    cout << "YES";
    exit(0);
}

void no()
{
    cout << "NO";
    exit(0);
}

bool check()
{
    memset(d , 0 ,sizeof d);
    for(int i = 1;i<=n;++i)
    {
        if (mark[i])
            continue;
        for(auto x:g[i])
        {
            if (!x)
                continue;
            d[x]++;
        }
    }
    vector<int> v;
    for(int i = 1;i<=n;++i)
    {
        if (mark[i])
            continue;
        if (!d[i])
            v.push_back(i);
    }
    for(int i = 0;i<v.size();++i)
    {
        int u = v[i];
        for(auto x:g[u])
        {
            if (!x)
                continue;
            d[x]--;
            if (!d[x])
                v.push_back(x);
        }
    }
    if (v.size()==n-nw)
        yes();
}

int main()
{
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
    }
    for(int i = 1;i<=n;++i)
    {
        for(auto x:g[i])
            d[x]++;
    }
    vector<int> vc;
    for(int i = 1;i<=n;++i)
    {
        if (!d[i])
            vc.push_back(i);
    }
    for(int i = 0;i<vc.size();++i)
    {
        int v = vc[i];
        mark[v]++;
        for(auto x:g[v])
        {
            d[x]--;
            if (!d[x])
                vc.push_back(x);
        }
    }
    nw = vc.size();
    if (vc.size()==n)
        yes();
    set<int> st;
    for(int i = 1;i<=n;++i)
    {
        if (mark[i])
            continue;
        if (d[i]==1)
            st.insert(i);
    }
    for(int i = 1;i<=n;++i)
    {
        if (mark[i])
            continue;
        for(int j = 0;j<g[i].size();++j)
        {
            int u = g[i][j];
            if (st.count(u))
            {
                g[i][j] = 0;
                check();
                g[i][j] = u;
            }
        }
    }
    no();
    return 0;
}


//in the name of allah
#include<bits/stdc++.h>

#define len length()
#define forr(n) for(int i = 0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define vecin(type,vec,n) forr(n){type a;cin >> a;vec.push_back(a);}
#define multin(type,mul,n) forr(n){type motegh;cin >> motegh;mul.insert(motegh);}
#define arrout(arr,n) forr(n){cout << arr[i] << " ";}
#define mapfor(type1,type2,con) for(map<type1,type2>::iterator it = con.begin();it!=con.end();++it)
#define setfor(type,con) for(set<type>::iterator it = con.begin();it!=con.end();++it)
#define arrin(arr,n) for(int i = 0;i<n;++i){cin >> arr[i];}
#define N 5163
#define MAX_N 110000
#define pb push_back
const ull MOD = 1e9 + 7;

using namespace std;

ll stol(string s)
{
    ll number = 0;
    for(int i = 0;i<s.length();++i)
        number+=(s[i]-'0')*powl(10,s.length()-1 - i);
    return number;
}

string to_string(ll number)
{
    string s = "";
    while(number>0)
    {
        string l = "";
        l+=(number%10)+'0';
        s = l + s;
        number/=10;
    }
    return s;
}

bool comp(ll a,ll b)
{
    return a > b;
}

int mark[MAX_N];
vector<ll> g[MAX_N];
int found = false;
vector<int> cycle;

void dfs(int v)
{
    if (found)
        return;
    for(int i = 0;i<g[v].size();++i)
    {
        if (found)
            return;
        int u = g[v][i];
        mark[v] = u;
        if (mark[u])
        {
            found++;
            if (cycle.size())
                break;
            u = mark[v];
            cycle.pb(v);
            mark[v]=-1;
            while(mark[u]!=-1)
            {
                cycle.pb(u);
                int t = mark[u];
                mark[u] = -1;
                u = t;
            }
            cycle.pb(u);
            return;
        }
        else
            dfs(u);
    }
    mark[v] = 0;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    ll n,m;
    cin >> n >> m;
    for(int i = 0;i<m;++i)
    {
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
    }
    for(int i = 1;i<=n;++i)
    {
        if (found)
            break;
        else
            dfs(i);
    }
    if (!found)
        return cout << "YES",0;
    for(int i = 0;i<cycle.size()-1;++i)
    {
        int v = cycle[i];
        int u = cycle[i+1];
        vector<ll>::iterator it = find(g[v].begin(),g[v].end(),u);
        g[v].erase(it);
        found = 0;
        for(int j = 1;j<=n;++j)
            mark[j] = 0;
        for(int j = 1;j<=n;++j)
        {
            if (found)
                break;
            else
                dfs(j);
        }
        if (!found)
            return cout << "YES",0;
        g[v].pb(u);
    }
    cout << "NO";
    return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

bool over;
int jala[501],before[501];
vector <int> ciclo,ciclo2;

void Deep(vector <int> v[], int jala[], int x)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y);
			}
			else
			{
				over=true;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f;
	scanf("%d %d",&n,&e);
	int jala[n];
	int before[n];
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		ciclo2=ciclo;
		for(i=0;i<ciclo.size();i++)
		{
			over=false;
			s=ciclo[i];
			e=ciclo.size();
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < e; ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			ciclo=ciclo2;
			edges[s].push_back(f);
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

const int mx=501;

bool over;
int jala[mx],before[mx];
vector <int> ciclo,ciclo2;

void Deep(vector <int> v[], int x)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y);
			}
			else
			{
				over=true;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f;
	scanf("%d %d",&n,&e);
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		e=ciclo.size();
		ciclo2=ciclo;
		for(i=0;i<e;i++)
		{
			over=false;
			s=ciclo[i];
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < edges[s].size(); ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			edges[s].push_back(f);
			ciclo=ciclo2;
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

const int mx=501;

bool over;
int jala[mx],before[mx];
vector <int> ciclo;

void Deep(vector <int> v[], int x,bool r)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y,r);
			}
			else
			{
				over=true;
				if(r) return;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f,k;
	scanf("%d %d",&n,&e);
	int jala[n];
	int before[n];
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i,false);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		k=ciclo.size();
		for(i=0;i<k;i++)
		{
			over=false;
			s=ciclo[i];
			e=ciclo.size();
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < e; ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j,true);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			edges[s].push_back(f);
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

bool over;
int jala[501],before[501];
vector <int> ciclo;

void Deep(vector <int> v[], int x)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y);
			}
			else
			{
				over=true;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f;
	scanf("%d %d",&n,&e);
	int jala[n];
	int before[n];
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		vector <int> ciclo2=ciclo;
		for(i=0;i<ciclo.size();i++)
		{
			over=false;
			s=ciclo[i];
			e=ciclo.size();
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < e; ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			ciclo=ciclo2;
			edges[s].push_back(f);
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

const int mx=501;

bool over;
int jala[mx],before[mx];
vector <int> ciclo,ciclo2;

void Deep(vector <int> v[], int x)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y);
			}
			else
			{
				over=true;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f;
	scanf("%d %d",&n,&e);
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		e=ciclo.size();
		ciclo2=ciclo;
		for(i=0;i<e;i++)
		{
			over=false;
			s=ciclo[i];
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < e; ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			edges[s].push_back(f);
			ciclo=ciclo2;
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

bool over;
int jala[501],before[501];
vector <int> ciclo,ciclo2;

void Deep(vector <int> v[], int x)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y);
			}
			else
			{
				over=true;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f;
	scanf("%d %d",&n,&e);
	int jala[n];
	int before[n];
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		ciclo2=ciclo;
		for(i=0;i<ciclo.size();i++)
		{
			over=false;
			s=ciclo[i];
			e=ciclo.size();
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < e; ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			ciclo=ciclo2;
			edges[s].push_back(f);
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;

const int mx=501;

bool over;
int jala[mx],before[mx];
vector <int> ciclo;

void Deep(vector <int> v[], int x,bool r)
{
	int i,y;
	if(over)
	{
		return;
	}
	jala[x]=1;
	for (i = 0; i < v[x].size(); ++i)
	{
		if(over)
		{
			return;
		}
		y=v[x][i];
		if(jala[y]<2)
		{
			before[y]=x;
			if(jala[y]<1)
			{
				jala[y]=1;
				Deep(v,y,r);
			}
			else
			{
				over=true;
				if(r) return;
				y=x;
				do
				{
					ciclo.push_back(y);
					y=before[y];
				}while(x!=y);
			}
		}
	}
	jala[x]=2;
	return;
}

int main(void)
{
	int n,e;
	int i,j;
	int s,f;
	scanf("%d %d",&n,&e);
	vector <int> edges[n];
	over=false;
	while(e--)
	{
		scanf("%d %d",&s,&f);
		edges[s-1].push_back(f-1);
	}
	memset(jala,0,sizeof(jala));
	for (i = 0; i < n; ++i)
	{
		if(!over)
		{
			Deep(edges,i,false);
		}
		else
		{
			break;
		}
	}
	if(!over)
	{
		printf("YES\n");
	}
	else
	{
		e=ciclo.size();
		for(i=0;i<e;i++)
		{
			over=false;
			s=ciclo[i];
			f=ciclo[(i+e-1)%e];
			for (j = 0; j < e; ++j)
			{
				if(edges[s][j]==f)
				{
					edges[s].erase(edges[s].begin()+j);
					break;
				}
			}
			memset(jala,0,sizeof(jala));
			for (j = 0; j < n; j++)
			{
				if(!over)
				{
					Deep(edges,j,true);
				}
				else
				{
					break;
				}

			}
			if(!over)
			{
				printf("YES\n");
				break;
			}
			edges[s].push_back(f);
		}
		if(over)
		{
			printf("NO\n");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define pdd pair<double,double>
#define vec vector
#define iter iterator
#define REP(i,x,y) for (int i=x;i<=y;i++)
#define DWN(i,x,y) for (int i=x;i>=y;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template<class Tp>Tp mymin(Tp x,Tp y){
    return x<y?x:y;
}
#define min mymin
template<class Tp>Tp mymax(Tp x,Tp y){
    return x<y?y:x;
}
#define max mymax
template<class Tp>Tp myabs(Tp x){
    return x<0?-x:x;
}
#define abs myabs
template<class Tp>void myswap(Tp &x,Tp &y){
    Tp z=x;x=y,y=z;
}
#define swap myswap
template<class Tp>Tp read(){
    Tp res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define uread() (read<unsigned long long>())
const int maxn=505;
const int maxe=100005;
struct Edge{
    int from,to,id,nxt;
}edges[maxe];
int n,m,E_cnt,lst[maxn],dfn[maxn],dfs_clock,tot,c[maxn];
bool isback[maxn],flag;
inline void add_edge(int from,int to){
    edges[++E_cnt]=(Edge){from,to,0,lst[from]};
    lst[from]=E_cnt;
}
inline void dfs(int u){
    dfn[u]=++dfs_clock;
    for (int i=lst[u];~i;i=edges[i].nxt){
        Edge &e=edges[i];
        if(dfn[e.to]){
            if(dfn[e.to]<dfn[u]){
                c[u]++,c[e.to]--,tot++,isback[u]=true;
            }
            else{
                if(isback[u]) flag=true;
            }
        }
        else dfs(e.to),c[u]+=c[e.to];
    }
}
int main(){
    memset(lst,-1,sizeof(lst));
    n=iread(),m=iread(),E_cnt=-1;
    REP(i,1,m){
        int from=iread(),to=iread();
        add_edge(from,to);
    }
    flag=false;
    REP(i,1,n){
        if(!dfn[i]) dfs(i);
    }
    if(!flag){
        bool mark=false;
        REP(i,1,n){
            printf("%d %d %d\n",i,c[i],tot);
            if(c[i]==tot){
                mark=true;
                break;
            }
        }
        if(!mark) printf("NO\n");
        else printf("YES\n");
    }
    else{
        if(tot>1) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define pdd pair<double,double>
#define vec vector
#define iter iterator
#define REP(i,x,y) for (int i=x;i<=y;i++)
#define DWN(i,x,y) for (int i=x;i>=y;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template<class Tp>Tp mymin(Tp x,Tp y){
    return x<y?x:y;
}
#define min mymin
template<class Tp>Tp mymax(Tp x,Tp y){
    return x<y?y:x;
}
#define max mymax
template<class Tp>Tp myabs(Tp x){
    return x<0?-x:x;
}
#define abs myabs
template<class Tp>void myswap(Tp &x,Tp &y){
    Tp z=x;x=y,y=z;
}
#define swap myswap
template<class Tp>Tp read(){
    Tp res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define uread() (read<unsigned long long>())
const int maxn=505;
const int maxe=100005;
struct Edge{
    int from,to,id,nxt;
}edges[maxe];
int n,m,E_cnt,lst[maxn],dfn[maxn],dfs_clock,tot,c[maxn],low[maxn];
bool vis[maxn],flag;
inline void add_edge(int from,int to){
    edges[++E_cnt]=(Edge){from,to,0,lst[from]};
    lst[from]=E_cnt;
}
inline void dfs(int u){
    dfn[u]=low[u]=++dfs_clock;
    for (int i=lst[u];~i;i=edges[i].nxt){
        Edge &e=edges[i];
        if(dfn[e.to]){
            if(!vis[e.to]){
                c[u]++,c[e.to]--,tot++;
                low[u]=min(low[u],dfn[e.to]);
            }
            else{
                if(low[e.to]<dfn[e.to]) flag=true;
            }
        }
        else{
            dfs(e.to),c[u]+=c[e.to];
            low[u]=min(low[u],low[e.to]);
        }
    }
    vis[u]=true;
}
int main(){
    memset(lst,-1,sizeof(lst));
    n=iread(),m=iread(),E_cnt=-1;
    REP(i,1,m){
        int from=iread(),to=iread();
        add_edge(from,to);
    }
    flag=false;
    REP(i,1,n){
        if(!dfn[i]) dfs(i);
    }
    if(!flag){
        bool mark=false;
        REP(i,1,n){
            if(c[i]==tot){
                mark=true;
                break;
            }
        }
        if(!mark) printf("NO\n");
        else printf("YES\n");
    }
    else{
        if(tot>1) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define pdd pair<double,double>
#define vec vector
#define iter iterator
#define REP(i,x,y) for (int i=x;i<=y;i++)
#define DWN(i,x,y) for (int i=x;i>=y;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template<class Tp>Tp mymin(Tp x,Tp y){
    return x<y?x:y;
}
#define min mymin
template<class Tp>Tp mymax(Tp x,Tp y){
    return x<y?y:x;
}
#define max mymax
template<class Tp>Tp myabs(Tp x){
    return x<0?-x:x;
}
#define abs myabs
template<class Tp>void myswap(Tp &x,Tp &y){
    Tp z=x;x=y,y=z;
}
#define swap myswap
template<class Tp>Tp read(){
    Tp res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define uread() (read<unsigned long long>())
const int maxn=505;
const int maxe=100005;
struct Edge{
    int from,to,nxt;
}edges[maxe];
int n,m,E_cnt,lst[maxn],indeg[maxn],ndeg[maxn];
int Q[maxn],hed,til;
inline void add_edge(int from,int to){
    edges[++E_cnt]=(Edge){from,to,lst[from]};
    lst[from]=E_cnt;
}
inline bool toposort(){
    hed=1,til=0;
    REP(i,1,n){
        if(!ndeg[i]) Q[++til]=i;
    }
    while(hed!=til+1){
        int u=Q[hed++];
        for (int i=lst[u];~i;i=edges[i].nxt){
            Edge &e=edges[i];
            if(!ndeg[e.to]) continue;
            ndeg[e.to]--;
            if(!ndeg[e.to]) Q[++til]=e.to;
        }
    }
    return til==n;
}
int main(){
    memset(lst,-1,sizeof(lst));
    n=iread(),m=iread(),E_cnt=-1;
    REP(i,1,m){
        int from=iread(),to=iread();
        add_edge(from,to),indeg[to]++;
    }
    REP(i,1,n){
        memcpy(ndeg,indeg,sizeof(ndeg));
        ndeg[i]--;
        if(toposort()){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define pdd pair<double,double>
#define vec vector
#define iter iterator
#define REP(i,x,y) for (int i=x;i<=y;i++)
#define DWN(i,x,y) for (int i=x;i>=y;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template<class Tp>Tp mymin(Tp x,Tp y){
    return x<y?x:y;
}
#define min mymin
template<class Tp>Tp mymax(Tp x,Tp y){
    return x<y?y:x;
}
#define max mymax
template<class Tp>Tp myabs(Tp x){
    return x<0?-x:x;
}
#define abs myabs
template<class Tp>void myswap(Tp &x,Tp &y){
    Tp z=x;x=y,y=z;
}
#define swap myswap
template<class Tp>Tp read(){
    Tp res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define uread() (read<unsigned long long>())
const int maxn=505;
const int maxe=100005;
struct Edge{
    int from,to,id,nxt;
}edges[maxe];
int n,m,E_cnt,lst[maxn],dfn[maxn],dfs_clock,tot,c[maxn];
inline void add_edge(int from,int to){
    edges[++E_cnt]=(Edge){from,to,0,lst[from]};
    lst[from]=E_cnt;
}
inline void dfs(int u){
    dfn[u]=++dfs_clock;
    for (int i=lst[u];~i;i=edges[i].nxt){
        Edge &e=edges[i];
        if(dfn[e.to]) c[u]++,c[e.to]--,tot++;
        else dfs(e.to),c[u]+=c[e.to];
    }
}
int main(){
    memset(lst,-1,sizeof(lst));
    n=iread(),m=iread(),E_cnt=-1;
    REP(i,1,m){
        int from=iread(),to=iread();
        add_edge(from,to);
    }
    REP(i,1,n){
        if(!dfn[i]) dfs(i);
    }
    bool flag=false;
    REP(i,1,n){
        if(c[i]==tot){
            flag=true;
            break;
        }
    }
    if(!flag) printf("NO\n");
    else printf("YES\n");
    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define pdd pair<double,double>
#define vec vector
#define iter iterator
#define REP(i,x,y) for (int i=x;i<=y;i++)
#define DWN(i,x,y) for (int i=x;i>=y;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template<class Tp>Tp mymin(Tp x,Tp y){
    return x<y?x:y;
}
#define min mymin
template<class Tp>Tp mymax(Tp x,Tp y){
    return x<y?y:x;
}
#define max mymax
template<class Tp>Tp myabs(Tp x){
    return x<0?-x:x;
}
#define abs myabs
template<class Tp>void myswap(Tp &x,Tp &y){
    Tp z=x;x=y,y=z;
}
#define swap myswap
template<class Tp>Tp read(){
    Tp res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define uread() (read<unsigned long long>())
const int maxn=505;
const int maxe=100005;
struct Edge{
    int from,to,id,nxt;
}edges[maxe];
int n,m,E_cnt,lst[maxn],dfn[maxn],dfs_clock,tot,c[maxn];
bool isback[maxn],flag;
inline void add_edge(int from,int to){
    edges[++E_cnt]=(Edge){from,to,0,lst[from]};
    lst[from]=E_cnt;
}
inline void dfs(int u){
    dfn[u]=++dfs_clock;
    for (int i=lst[u];~i;i=edges[i].nxt){
        Edge &e=edges[i];
        if(dfn[e.to]){
            if(dfn[e.to]<dfn[u]){
                c[u]++,c[e.to]--,tot++,isback[u]=true;
            }
            else{
                if(isback[u]) flag=true;
            }
        }
        else dfs(e.to),c[u]+=c[e.to];
    }
}
int main(){
    memset(lst,-1,sizeof(lst));
    n=iread(),m=iread(),E_cnt=-1;
    REP(i,1,m){
        int from=iread(),to=iread();
        add_edge(from,to);
    }
    flag=false;
    REP(i,1,n){
        if(!dfn[i]) dfs(i);
    }
    if(!flag){
        bool mark=false;
        REP(i,1,n){
            if(c[i]==tot){
                mark=true;
                break;
            }
        }
        if(!mark) printf("NO\n");
        else printf("YES\n");
    }
    else{
        if(tot>1) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define pdd pair<double,double>
#define vec vector
#define iter iterator
#define REP(i,x,y) for (int i=x;i<=y;i++)
#define DWN(i,x,y) for (int i=x;i>=y;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template<class Tp>Tp mymin(Tp x,Tp y){
    return x<y?x:y;
}
#define min mymin
template<class Tp>Tp mymax(Tp x,Tp y){
    return x<y?y:x;
}
#define max mymax
template<class Tp>Tp myabs(Tp x){
    return x<0?-x:x;
}
#define abs myabs
template<class Tp>void myswap(Tp &x,Tp &y){
    Tp z=x;x=y,y=z;
}
#define swap myswap
template<class Tp>Tp read(){
    Tp res=0,f_f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f_f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<3)+(res<<1)-'0'+ch,ch=getchar();
    return res*f_f;
}
#define iread() (read<int>())
#define lread() (read<long long>())
#define uread() (read<unsigned long long>())
const int maxn=505;
const int maxe=100005;
struct Edge{
    int from,to,id,nxt;
}edges[maxe];
int n,m,E_cnt,lst[maxn],dfn[maxn],dfs_clock,tot,c[maxn],low[maxn];
bool vis[maxn],flag;
inline void add_edge(int from,int to){
    edges[++E_cnt]=(Edge){from,to,0,lst[from]};
    lst[from]=E_cnt;
}
inline void dfs(int u){
    dfn[u]=low[u]=++dfs_clock;
    for (int i=lst[u];~i;i=edges[i].nxt){
        Edge &e=edges[i];
        if(dfn[e.to]){
            low[u]=min(low[u],dfn[e.to]);
            if(!vis[e.to]) c[u]++,c[e.to]--,tot++;
            else{
                if(low[e.to]<dfn[e.to]) flag=true;
            }
        }
        else{
            dfs(e.to),c[u]+=c[e.to];
            low[u]=min(low[u],low[e.to]);
        }
    }
    vis[u]=true;
}
int main(){
    memset(lst,-1,sizeof(lst));
    n=iread(),m=iread(),E_cnt=-1;
    REP(i,1,m){
        int from=iread(),to=iread();
        add_edge(from,to);
    }
    flag=false;
    REP(i,1,n){
        if(!dfn[i]) dfs(i);
    }
    if(!flag){
        bool mark=false;
        REP(i,1,n){
            if(c[i]==tot){
                mark=true;
                break;
            }
        }
        if(!mark) printf("NO\n");
        else printf("YES\n");
    }
    else{
        if(tot>1) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int F()
{
	R int x; R char ch;
	while(ch = getchar(), ch < '0' || ch > '9'); x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = ch - '0' + x * 10;
	return x;
}
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1, type = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag && type) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag && type) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag && type)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u = F(), v = F();
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("YES");
		return 0;
	}
	type = flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[j] && DFS(j)){ flag = 1; break; }
		if(!flag){ puts("YES"); return 0; }
		flag = 0;
	}
	puts("NO");
	return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u, v;
		scanf("%d %d", &u, &v);
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("YES");
		return 0;
	} flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[j] && DFS(j)){ flag = 1; break; }
		if(!flag){ puts("YES"); return 0; }
		flag = 0;
	}
	puts("NO");
	return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u, v;
		scanf("%d %d", &u, &v);
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("YES");
		return 0;
	} flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[i] && DFS(i)){ flag = 1; break; }
		if(!flag){ puts("YES"); return 0; }
		flag = 0;
	}
	puts("NO");
	return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int F()
{
	R int x; R char ch;
	while(ch = getchar(), ch < '0' || ch > '9'); x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = ch - '0' + x * 10;
	return x;
}
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u = F(), v = F();
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("YES");
		return 0;
	} flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[j] && DFS(j)){ flag = 1; break; }
		if(!flag){ puts("YES"); return 0; }
		flag = 0;
	}
	puts("NO");
	return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int F()
{
	R int x; R char ch;
	while(ch = getchar(), ch < '0' || ch > '9'); x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = ch - '0' + x * 10;
	return x;
}
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1, type = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag && type) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag && type) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag && type)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u = F(), v = F();
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("NO");
		return 0;
	}
	type = 1; flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[j] && DFS(j)){ flag = 1; break; }
		if(!flag){ puts("NO"); return 0; }
		flag = 0;
	}
	puts("YES");
	return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int F()
{
	R int x; R char ch;
	while(ch = getchar(), ch < '0' || ch > '9'); x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = ch - '0' + x * 10;
	return x;
}
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1, type = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag && type) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag && type) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag && type)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u = F(), v = F();
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("NO");
		return 0;
	}
	type = flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[j] && DFS(j)){ flag = 1; break; }
		if(!flag){ puts("NO"); return 0; }
		flag = 0;
	}
	puts("YES");
	return 0;
}


#include <cstdio>
#include <cstring>
#define R register
int F()
{
	R int x; R char ch;
	while(ch = getchar(), ch < '0' || ch > '9'); x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = ch - '0' + x * 10;
	return x;
}
int n, m, Sta[510], tot, Test[510], cnt, Point[510], Next[100010], To[100010], q, missing;
bool vis[510], on_stack[510], flag = 1;
void Add(R int u, R int v){ Next[++q] = Point[u]; Point[u] = q; To[q] = v; }
bool DFS(R int u)
{
	vis[u] = on_stack[u] = 1;
	for(R int j = Point[u]; j; j = Next[j])
	{
		if(missing == j) continue;
		if(!vis[To[j]])
		{
			if(flag) Sta[++tot] = j;
			if(DFS(To[j])) return 1;
			if(flag) tot--;
		}
		else if(on_stack[To[j]])
		{
			if(flag)
			{
				Test[++cnt] = j;
				while(tot && To[Sta[tot]] != To[j]) Test[++cnt] = Sta[tot--];
			}
			return 1;
		}
	}
	on_stack[u] = 0;
	return 0;
}
int main()
{
	scanf("%d %d", &n, &m);
	for(R int i = 1; i <= m; i++)
	{
		R int u = F(), v = F();
		Add(u, v);
	}
	for(R int i = 1; i <= n; i++) if(!vis[i] && DFS(i)) break;
	if(cnt == 0)
	{
		puts("NO");
		return 0;
	} flag = 0;
	for(R int i = 1; i <= cnt; i++)
	{
		missing = Test[i];
		memset(vis, 0, sizeof(vis));
		memset(on_stack, 0, sizeof(on_stack));
		for(R int j = 1; j <= n; j++) if(!vis[j] && DFS(j)){ flag = 1; break; }
		if(!flag){ puts("NO"); return 0; }
		flag = 0;
	}
	puts("YES");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    if(cycle.size() > 500) {
      cout << "What" << endl;
      return 0;
    }
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int cycleDepth;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, int depth, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    cycleDepth = depth - 1;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], depth + 1, cycle)) {
      if(cycleDepth > 0) {
        cycle.push_back(v);
        --cycleDepth;
      }
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    if(!visited[i])
      if(hasCycle(i, 0, cycle))
        break;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    reverse(cycle.begin(), cycle.end());
    for(size_t i = 0; i < cycle.size() - 1; ++i) {
      e1 = cycle[i];
      e2 = cycle[i + 1];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int cycleDepth;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  return acyclicDFS(0);
  /*for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;*/
}

bool hasCycle(int v, int depth, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    cycleDepth = depth - 1;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], depth + 1, cycle)) {
      if(cycleDepth > 0) {
        cycle.push_back(v);
        --cycleDepth;
      }
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    if(!visited[i])
      if(hasCycle(i, 0, cycle))
        break;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  fill(visited.begin(), visited.end(), false);
  fill(closed.begin(), closed.end(), false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  visited = vector<bool>(n);
  closed = vector<bool>(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;
  if(visited[v])
    return true;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  fill(visited.begin(), visited.end(), false);
  fill(closed.begin(), closed.end(), false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v])
    return true;
  if(visited[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    cycle.push_back(graph[v][i]);
    if(hasCycle(graph[v][i], cycle))
      return true;
    cycle.pop_back();
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    cycle.push_back(i);
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  visited = vector<bool>(n);
  closed = vector<bool>(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 0; i < cycle.size() - 1; ++i) {
      e1 = cycle[i];
      e2 = cycle[i + 1];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i])
      if(hasCycle(i, cycle))
        break;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;
  if(visited[v])
    return true;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  fill(visited.begin(), visited.end(), false);
  fill(closed.begin(), closed.end(), false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }
  if(visited[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  visited = vector<bool>(n);
  closed = vector<bool>(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;
  if(visited[v])
    return true;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  fill(visited.begin(), visited.end(), false);
  fill(closed.begin(), closed.end(), false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  if(visited[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  visited = vector<bool>(n);
  closed = vector<bool>(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;
  if(visited[v])
    return true;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  fill(visited.begin(), visited.end(), false);
  fill(closed.begin(), closed.end(), false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  visited = vector<bool>(n);
  closed = vector<bool>(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int cycleDepth;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, int depth, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    cycleDepth = depth - 1;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], depth + 1, cycle)) {
      if(cycleDepth > 0) {
        cycle.push_back(v);
        --cycleDepth;
      }
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    if(!visited[i])
      if(hasCycle(i, 0, cycle))
        break;
  }
  return cycle;
}

int main() {

  cin >> n >> m;

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    reverse(cycle.begin(), cycle.end());
    for(size_t i = 0; i < cycle.size() - 1; ++i) {
      e1 = cycle[i];
      e2 = cycle[i + 1];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int cycleDepth;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, int depth, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    cycleDepth = depth - 1;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], depth + 1, cycle)) {
      if(cycleDepth > 0) {
        cycle.push_back(v);
        --cycleDepth;
      }
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    if(!visited[i])
      if(hasCycle(i, 0, cycle))
        break;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = cycle.size() - 1; i > 0; --i) {
      e1 = cycle[i];
      e2 = cycle[i - 1];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  if(visited[v] && !closed[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector< vector<int> > graph;
int n, m;
vector<bool> visited;
vector<bool> closed;
int e1 = -1, e2 = -1;
int intersection;
bool intersectionMet;

bool acyclicDFS(int v) {
  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(v == e1 && graph[v][i] == e2)
      continue;
    else if(visited[graph[v][i]] && !closed[graph[v][i]])
      return false;
    else if(visited[graph[v][i]])
      return true;

    if(!acyclicDFS(graph[v][i]))
      return false;
  }
  closed[v] = true;
  return true;
}

bool isAcyclic() {
  fill(visited.begin(), visited.end(), false);
  fill(closed.begin(), closed.end(), false);
  for(int i = 0; i < n; ++i) {
    if(!visited[i] && !acyclicDFS(i))
      return false;
  }
  return true;
}

bool hasCycle(int v, vector<int> & cycle) {
  if(visited[v] && !closed[v]) {
    intersection = v;
    cycle.push_back(v);
    return true;
  }

  if(visited[v])
    return false;

  visited[v] = true;
  for(size_t i = 0; i < graph[v].size(); ++i) {
    if(hasCycle(graph[v][i], cycle)) {
      if(!intersectionMet)
        cycle.push_back(v);
      if(intersection == v)
        intersectionMet = true;
      return true;
    }
  }
  closed[v] = true;
  return false;
}

vector<int> getCycle() {
  vector<int> cycle;
  visited = vector<bool>(n, false);
  closed = vector<bool>(n, false);
  for(int i = 0; i < n; ++i) {
    cycle.clear();
    intersection = -1;
    intersectionMet = false;
    if(!visited[i] && hasCycle(i, cycle))
      return cycle;
  }
  return cycle;
}

int main() {

  scanf("%d %d", &n, &m);

  graph = vector< vector<int> >(n);
  visited = vector<bool>(n);
  closed = vector<bool>(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    graph[u - 1].push_back(v - 1);
  }

  if(isAcyclic()) {
    cout << "YES" << endl;
  } else {
    vector<int> cycle = getCycle();
    for(size_t i = 1; i < cycle.size() - 1; ++i) {
      e1 = cycle[i - 1];
      e2 = cycle[i];
      if(isAcyclic()) {
        cout << "YES" << endl;
        return 0;
      }
    }
    cout << "NO" << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define ff first
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second
#define S(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
int n , m  , x , y , cnt , p ;
vector<vector<int> > g(502) ;
int eg[502][502] ;
int par[502] ;
int mark[502]={0} ;
 int vis[502]={0} ;
int dfs(int k )
{
	//cout<<k<<endl;
	vis[k]=1 ;
	mark[k]=1 ;

	for(int i=0;i<g[k].size();i++)
	{
		if(cnt==1)
		{
			return 0 ;
		}

		if(vis[g[k][i]]==0)
		{
			par[g[k][i]]=k ;
			dfs(g[k][i]) ;
		}

		else if(mark[g[k][i]]==1)
		{
			//cout<<mark[g[k][i]]<<endl;
		    par[g[k][i]]=k ;
		    p = g[k][i] ;
			cnt++ ;
			return 0 ;
		}
	}

	mark[k]=0 ;
}

int dfs1(int k)
{
	vis[k]=1 ;
	mark[k]=1 ;
	cout<<k<<endl;
	for(int i=0;i<g[k].size();i++)
	{
		if(eg[k][g[k][i]]==-1)
			continue ;
		if(vis[g[k][i]]==0)
		{
			dfs1(g[k][i]) ;
		}
		else if(mark[g[k][i]]==1)
		{
			cnt++ ;
		}
	}

	mark[k]=0 ;
}
int main()
{
  S(n);
  S(m) ;
  int ans=0 ;
  //eg.pb({0,0}) ;
  for(int i=0;i<m;i++)
  {
  	 int u , v ;
  	 S(u) ;
  	 S(v) ;
  	 g[u].pb(v) ;
  	// eg.pb({u,v}) ;
  }

      cnt=0 ;
      for(int j=1;j<=n;j++)
      {
      	 if(vis[j]==0)
      	 {
      	 	par[j]=j ;
      	 	dfs(j) ;
      	 	if(cnt>0)
      	 		break ;
      	 }

      }

     // cout<<p<<endl;
      for(int i=1;i<=n;i++)
      {
      // cout<<par[i]<<endl;
      }
      int c=p ;
      int t =1 ;
      while(p!=c||t==1)
      {
      	  //cout<<par[p]<<" "<<p<<endl;
      	  //eg[par[p]][p]= -1 ;
      	  t++ ;

          memset(vis,0,sizeof(vis)) ;
          memset(mark,0,sizeof(mark)) ;
      	  //p=par[p] ;

      	  for(int j=1;j<=n;j++)
      	  {
      	  	 x=par[p] ; y=p ;
      	  	 dfs(j) ;
      	  	 if(cnt>=1)
      	  	 {
      	  	 	cout<<"NO\n" ;
      	  	 	return 0;
      	  	 }
      	  }
      }

      cout<<"YES\n" ;

}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define ff first
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second
#define S(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
int n , m  , x , y , cnt , p ;
vector<vector<int> > g(502) ;
int eg[502][502] ;
int par[502] ;
int mark[502]={0} ;
 int vis[502]={0} ;
int dfs(int k )
{
	//cout<<k<<endl;
	vis[k]=1 ;
	mark[k]=1 ;

	for(int i=0;i<g[k].size();i++)
	{
		if(cnt==1)
		{
			return 0 ;
		}

		if(vis[g[k][i]]==0)
		{
			par[g[k][i]]=k ;
			dfs(g[k][i]) ;
		}

		else if(mark[g[k][i]]==1)
		{
			//cout<<mark[g[k][i]]<<endl;
		    par[g[k][i]]=k ;
		    p = g[k][i] ;
			cnt++ ;
			return 0 ;
		}
	}

	mark[k]=0 ;
}

int dfs1(int k)
{
	vis[k]=1 ;
	mark[k]=1 ;
	//cout<<k<<endl;
	for(int i=0;i<g[k].size();i++)
	{
		if(k=x&&g[k][i]==y)
			continue ;
		if(vis[g[k][i]]==0)
		{
			dfs1(g[k][i]) ;
		}
		else if(mark[g[k][i]]==1)
		{
			cnt++ ;
		}
	}

	mark[k]=0 ;
}
int main()
{
  S(n);
  S(m) ;
  int ans=0 ;
  //eg.pb({0,0}) ;
  for(int i=0;i<m;i++)
  {
  	 int u , v ;
  	 S(u) ;
  	 S(v) ;
  	 g[u].pb(v) ;
  	// eg.pb({u,v}) ;
  }

      cnt=0 ;
      for(int j=1;j<=n;j++)
      {
      	 if(vis[j]==0)
      	 {
      	 	par[j]=j ;
      	 	dfs(j) ;
      	 	if(cnt>0)
      	 		break ;
      	 }

      }

     // cout<<p<<endl;
      for(int i=1;i<=n;i++)
      {
      // cout<<par[i]<<endl;
      }
      int c=p ;
      int t =1 ;
      while(p!=c||t==1)
      {
      	  //cout<<par[p]<<" "<<p<<endl;
      	  //eg[par[p]][p]= -1 ;
      	  t++ ;

          memset(vis,0,sizeof(vis)) ;
          memset(mark,0,sizeof(mark)) ;
      	  //p=par[p] ;

      	  for(int j=1;j<=n;j++)
      	  {
      	  	 x=par[p] ; y=p ;
      	  	 dfs1(j) ;
      	  	 if(cnt>=1)
      	  	 {
      	  	 	cout<<"NO\n" ;
      	  	 	return 0;
      	  	 }
      	  }
      	  p=par[p] ;
      }

      cout<<"YES\n" ;

}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define ff first
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second
#define S(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
int n , m  , x , y , cnt ;
vector<vector<int> > g(502) ;
vector<pair<int,int> > eg ;

int dfs(int k , int vis[502] , int mark[502])
{
	vis[k]=1 ;
	mark[k]=1 ;
	for(int i=0;i<g[k].size();i++)
	{
		if(x==k&&g[k][i]==y)
		{
			continue ;
		}
		if(vis[g[k][i]]==0)
		{
			dfs(g[k][i],vis,mark) ;
		}

		else if(mark[g[k][i]]==1)
		{
			cnt++ ;
		}
	}

	mark[k]=0 ;
}

int main()
{
  S(n);
  S(m) ;
  int ans=0 ;
  eg.pb({0,0}) ;
  for(int i=0;i<m;i++)
  {
  	 int u , v ;
  	 S(u) ;
  	 S(v) ;
  	 g[u].pb(v) ;
  	 eg.pb({u,v}) ;
  }

  for(int i=0;i<eg.size();i++)
  {
      x=eg[i].ff ;
      y=eg[i].ss ;

      int mark[502]={0} ;
      int vis[502]={0} ;
      cnt=0 ;
      for(int j=1;j<=n;j++)
      {
      	 if(vis[j]==0)
      	 {
      	 	dfs(j,vis,mark) ;
      	 }

      }

      if(cnt==0)
      {
      	 ans=1 ;
      	 break ;
      }
  }

  if(ans==1)
  {
  	 cout<<"YES\n" ;
  }
  else
  {
  	cout<<"NO\n" ;
  }
}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define ff first
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second
#define S(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
int n , m  , x , y , cnt , p ;
vector<vector<int> > g(502) ;
int eg[502][502] ;
int par[502] ;
int mark[502]={0} ;
 int vis[502]={0} ;
int dfs(int k )
{
	//cout<<k<<endl;
	vis[k]=1 ;
	mark[k]=1 ;

	for(int i=0;i<g[k].size();i++)
	{
		if(cnt==1)
		{
			return 0 ;
		}

		if(vis[g[k][i]]==0)
		{
			par[g[k][i]]=k ;
			dfs(g[k][i]) ;
		}

		else if(mark[g[k][i]]==1)
		{
			//cout<<mark[g[k][i]]<<endl;
		    par[g[k][i]]=k ;
		    p = g[k][i] ;
			cnt++ ;
			return 0 ;
		}
	}

	mark[k]=0 ;
}

int dfs1(int k)
{
	vis[k]=1 ;
	mark[k]=1 ;
	//cout<<k<<endl;
	for(int i=0;i<g[k].size();i++)
	{
		if(k==x&&g[k][i]==y)
			continue ;
		if(vis[g[k][i]]==0)
		{
			dfs1(g[k][i]) ;
		}
		else if(mark[g[k][i]]==1)
		{
			//cout<<g[k][i]<<endl;
			cnt++ ;
		}
	}

	mark[k]=0 ;
}
int main()
{
  S(n);
  S(m) ;
  int ans=0 ;
  //eg.pb({0,0}) ;
  for(int i=0;i<m;i++)
  {
  	 int u , v ;
  	 S(u) ;
  	 S(v) ;
  	 g[u].pb(v) ;
  	// eg.pb({u,v}) ;
  }

      cnt=0 ;
      for(int j=1;j<=n;j++)
      {
      	 if(vis[j]==0)
      	 {
      	 	par[j]=j ;
      	 	dfs(j) ;
      	 	if(cnt>0)
      	 		break ;
      	 }

      }

     // cout<<p<<endl;
      for(int i=1;i<=n;i++)
      {
      // cout<<par[i]<<endl;
      }
      int c=p ;
      int t =1 ;
      cnt=0 ;

      while(p!=c||t==1)
      {
      	  cnt=0 ;
      	  //cout<<par[p]<<" "<<p<<endl;
      	  //eg[par[p]][p]= -1 ;
      	  t++ ;

          memset(vis,0,sizeof(vis)) ;
          memset(mark,0,sizeof(mark)) ;
      	  //p=par[p] ;

      	  for(int j=1;j<=n;j++)
      	  {
      	  	 x=par[p] ; y=p ;
      	  	 dfs1(j) ;
      	  }

      	  if(cnt==0)
      	  {
      	  	 cout<<"YES\n" ;
      	  	 return 0;
      	  }
      	  p=par[p] ;
      }

      cout<<"NO\n" ;

}


#include <bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define ff first
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second
#define S(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()
int n , m  , x , y , cnt , p ;
vector<vector<int> > g(502) ;
int eg[502][502] ;
int par[502] ;
int mark[502]={0} ;
 int vis[502]={0} ;
int dfs(int k )
{
	//cout<<k<<endl;
	vis[k]=1 ;
	mark[k]=1 ;

	for(int i=0;i<g[k].size();i++)
	{
		if(cnt==1)
		{
			return 0 ;
		}

		if(vis[g[k][i]]==0)
		{
			par[g[k][i]]=k ;
			dfs(g[k][i]) ;
		}

		else if(mark[g[k][i]]==1)
		{
			//cout<<mark[g[k][i]]<<endl;
		    par[g[k][i]]=k ;
		    p = g[k][i] ;
			cnt++ ;
			return 0 ;
		}
	}

	mark[k]=0 ;
}

int dfs1(int k)
{
	vis[k]=1 ;
	mark[k]=1 ;
	//cout<<k<<endl;
	for(int i=0;i<g[k].size();i++)
	{
		if(k==x&&g[k][i]==y)
			continue ;
		if(vis[g[k][i]]==0)
		{
			dfs1(g[k][i]) ;
		}
		else if(mark[g[k][i]]==1)
		{
			cnt++ ;
		}
	}

	mark[k]=0 ;
}
int main()
{
  S(n);
  S(m) ;
  int ans=0 ;
  //eg.pb({0,0}) ;
  for(int i=0;i<m;i++)
  {
  	 int u , v ;
  	 S(u) ;
  	 S(v) ;
  	 g[u].pb(v) ;
  	// eg.pb({u,v}) ;
  }

      cnt=0 ;
      for(int j=1;j<=n;j++)
      {
      	 if(vis[j]==0)
      	 {
      	 	par[j]=j ;
      	 	dfs(j) ;
      	 	if(cnt>0)
      	 		break ;
      	 }

      }

     // cout<<p<<endl;
      for(int i=1;i<=n;i++)
      {
      // cout<<par[i]<<endl;
      }
      int c=p ;
      int t =1 ;
      cnt=0 ;

      while(p!=c||t==1)
      {
      	  cnt=0 ;
      	  //cout<<par[p]<<" "<<p<<endl;
      	  //eg[par[p]][p]= -1 ;
      	  t++ ;

          memset(vis,0,sizeof(vis)) ;
          memset(mark,0,sizeof(mark)) ;
      	  //p=par[p] ;

      	  for(int j=1;j<=n;j++)
      	  {
      	  	 x=par[p] ; y=p ;
      	  	 dfs1(j) ;
      	  	 if(cnt==0)
      	  	 {
      	  	 	cout<<"YES\n" ;
      	  	 	return 0;
      	  	 }
      	  }
      	  p=par[p] ;
      }

      cout<<"NO\n" ;

}


size = int(raw_input())
arr = map(int, raw_input().split(' '))
arr = [int(i) for i in arr]
maximum =1
series =1
for i in range(1,size):
    if arr[i-1] < arr[i]:
        series += 1
        if maximum<series:
            maximum=series
    else:
        series=1

print maximum


size = int(raw_input())
series =1
max =0
current = int(raw_input())
for i in range(1,size):
    temp = int(raw_input())
    if current < temp:
        series += 1
    else:
        if max<series:
            max = series
        series=1

    current = temp

if max<series:
	max = series
print max


size = int(raw_input())
series =1
maximum =0
current = int(raw_input())
for i in range(1,size):
    temp = int(raw_input())
    if current < temp:
        series += 1
    else:
        if maximum<series:
            maximum = series
        series=1

    current = temp

if maximum<series:
	maximum = series
print maximum


n = int(raw_input())
a = [int(i) for i in raw_input().split()]
ans = 1
p = 1
for i in range(1, n):
    if a[i] > a[i - 1]:
        p = p + 1
    else:
        p = 1
    ans = max(ans, p)
print ans


n = int(raw_input())
a = [int(i) for i in raw_input().split()]
ans = 0
p = 1
for i in range(1, n):
    if a[i] > a[i - 1]:
        p = p + 1
    else:
        p = 1
    ans = max(ans, p)
print ans


n=int(raw_input())
a=map(int,raw_input().split())
l=1
for i in xrange(n-1):
	if a[i]<a[i+1]:
		l+=1
	else:
		l=1
print l


n=int(raw_input())
a=map(int,raw_input().split())
l=1
if n==1:
	print 1
	exit()
for i in xrange(n-1):
	if a[i]<a[i+1]:
		l+=1
	else:
		l=1
print l


n=int(raw_input())
a=map(int,raw_input().split())
l=1
m=1
if n==1:
	print 1
	exit()
for i in xrange(n-1):
	if a[i]<a[i+1]:
		l+=1
		m=max(m,l)
	else:
		l=1
print m


'''input
5
1 7 2 11 15
'''

ans = 0
n = int(raw_input())
arr = map(int,raw_input().split())
prev = -1
cnt = 0
for i in range (n):
	if(arr[i] > prev): cnt += 1
	else: cnt = 1

	prev = arr[i]
	ans = max(ans, cnt)

print ans


n = input()
inp = map(int,raw_input().split())
ans = 1
cur = 1
for i in xrange(1,n):
    if(inp[i]>inp[i-1]):
        cur+=1
    else:
        ans=max(cur,ans)
        cur=1
ans = max(cur,ans)
print ans


n = input()
inp = map(int,raw_input())
ans = 1
cur = 1
for i in xrange(1,n):
    if(inp[i]>inp[i-1]):
        cur+=1
    else:
        ans=max(cur,ans)
        cur=1
ans = max(cur,ans)
print ans