#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      bool check = false;
      double k;
      if (a[i].first.first - x != 0) k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
      else check = true;
      for (int j = i + 1; j < n; j++) {
        if (check && a[j].first.first == x) a[j].second = false;
        else if (a[j].first.second - y - k * (a[j].first.first - x) < 0.1) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      for (int j = i + 1; j < n; j++) {
        if ((a[i].first.first - x) * (a[j].first.second - y) == (a[j].first.first - x) * (a[i].first.second - y)) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      bool check = false;
      double k;
      if (a[i].first.first - x != 0) k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
      else check = true;
      for (int j = i + 1; j < n; j++) {
        if (check && a[j].first.first == x) a[j].second = false;
        else if (a[j].first.second - y - k * (a[j].first.first - x) < 0.0000000001) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      double k;
      if (a[i].first.first - x != 0) {
        k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.second - y == k * (a[j].first.first - x)) a[j].second = false;
        }
      }
      else {
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.first == x) a[j].second = false;
        }
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i].second) {
      for (int j = i + 1; j < n; j++) {
        if ((a[i].first.first - x) * (a[j].first.second - y) == (a[j].first.first - x) * (a[j].first.second - y)) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count == 0 ? 1 : count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i].second) {
      double k = (a[i].first.second - y) *1. / (a[i].first.first - x);
      for (int j = i + 1; j < n; j++) {
        if (a[j].first.second - y == k * (a[j].first.first - x)) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
using namespace std;
int main(){
    int n{0},x{0},y{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            shot++;
        }else if(b==y){
            shot++;
        }else{
            vec.push_back(std::make_pair(x,y));
        }
    }
    n=vec.size();
    vector<float> v;
    for(int i=0;i<n;i++){
        float c=(vec[i].second-y)/(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;
    cout<<shot<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
using namespace std;
int main(){
    int n{0},x{0},y{0},z{0},k{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            z=1;
        }else if(b==y){
            k=1;
        }else{
            vec.push_back(std::make_pair(a,b));
        }
    }
    shot=shot+z+k;
    n=vec.size();
    if(n!=0){
    vector<float> v;
    for(int i=0;i<n;i++){
        float c=(vec[i].second-y)/(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;}
    cout<<shot<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
using namespace std;
int main(){
    int n{0},x{0},y{0},z{0},k{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            z=1;
        }else if(b==y){
            k=1;
        }else{
            vec.push_back(std::make_pair(a,b));
        }
    }
    shot=shot+z+k;
    n=vec.size();
    if(n!=0){
    vector<float> v;
    for(int i=0;i<n;i++){
        float c=(float)(vec[i].second-y)/(float)(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;}
    cout<<shot<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
#include<iomanip>
using namespace std;
int main(){
    int n{0},x{0},y{0},z{0},k{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            z=1;
        }else if(b==y){
            k=1;
        }else{
            vec.push_back(std::make_pair(a,b));
        }
    }
    shot=shot+z+k;
    n=vec.size();
    if(n!=0){
    cout<<setprecision(9);
    vector<float> v;
    for(int i=0;i<n;i++){
        float c=(float)(vec[i].second-y)/(float)(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;}
    cout<<shot<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
#include<iomanip>
using namespace std;
int main(){
    int n{0},x{0},y{0},z{0},k{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            z=1;
        }else if(b==y){
            k=1;
        }else{
            vec.push_back(std::make_pair(a,b));
        }
    }
    shot=shot+z+k;
    n=vec.size();
    if(n!=0){
    cout<<setprecision(15);
    vector<double> v;
    for(int i=0;i<n;i++){
        double c=(double)(vec[i].second-y)/(double)(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;}
    cout<<shot<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
using namespace std;
int main(){
    int n{0},x{0},y{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            shot++;
        }else if(b==y){
            shot++;
        }else{
            vec.push_back(std::make_pair(a,b));
        }
    }
    n=vec.size();
    vector<float> v;
    for(int i=0;i<n;i++){
        float c=(vec[i].second-y)/(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;
    cout<<shot<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<utility>
using namespace std;
int main(){
    int n{0},x{0},y{0};
    cin>>n>>x>>y;
    long long int shot{0};
    vector<pair<int,int>> vec;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a==x){
            shot++;
        }else if(b==y){
            shot++;
        }else{
            vec.push_back(x,y);
        }
    }
    n=vec.size();
    vector<float> v;
    for(int i=0;i<n;i++){
        float c=(vec[i].second-y)/(vec[i].first-x);
        v.push_back(c);
    }
    sort(v.begin(),v.end());
    long long int count=1;
    for(int i=1;i<n;i++){
        if(v[i]!=v[i-1]){
            count++;
        }
    }
    shot+=count;
    cout<<shot<<endl;
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(v[j]+k==pi || v[j]==k)
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


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

typedef long long ll;

struct coordinate{
vector <ll> x,y;};

int main()
{
    ll n,x0,y0,a,b,i,j,count=0,state;
    coordinate point;
    cin>>n>>x0>>y0;

    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        point.x.push_back(a);
        point.y.push_back(b);
        state=0;
        for(j=0;j<point.x.size()-1;j++)
        {
            if((point.x[j]-x0)*(b-y0)==(point.y[j]-y0)*(a-x0))
                {
                    state=1;
                    break;
                }
        }
        if(state==0)
            count++;

    }

    cout<<count;
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (180*acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c*pi)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(v[j]+k==180 || fabs(v[j]-k==0))
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (180*acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c*pi)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(fabs(v[j]+k-180)<=0.000001 || fabs(v[j]-k)<=0.000001)
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(v[j]+k-pi<=0.00001 || v[j]-k<=0.00001)
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (180*acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c*pi)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(v[j]+k==180 || v[j]==k)
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (180*acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c*pi)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(fabs(v[j]+k-180)<=0.0001 || fabs(v[j]-k)<=0.0001)
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


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

double pi=acos(-1);

double distance(double x1, double y1,double x2,double y2)
{
    return (sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

double angle(double refx,double refy, double x1,double y1)
{
    double a=distance(1.5,1.5,x1,y1);
    double b=distance(refx,refy,1.5,1.5);
    double c=distance(refx,refy,x1,y1);
    return (180*acos((pow(b,2)+pow(c,2)-pow(a,2))/(2*b*c*pi)));
}

int main()
{
    double n,refx,refy,x1,y1,i,j,state,k;
    vector <double> v;
    cin>>n>>refx>>refy;
    for(i=0;i<n;i++)
    {
        cin>>x1>>y1;
        state=0;
        k=angle(refx,refy,x1,y1);
        for(j=0;j<v.size();j++)
        {
            if(fabs(v[j]+k-180)<=0.00001 || fabs(v[j]-k)<=0.00001)
                state=1;
            break;
        }
        if(state==0)
            v.push_back(k);
    }
    cout<<v.size();
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    slope[i] = dy / dx;

	}

	int count=1;

	sort(slope, slope + n);

	for(int i=1;i<n;i++){
		if(slope[i]!=slope[i-1]){
			count++;
		}
	}

	cout<<count;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    if(dy==0 && dx==0){
    	slope[i]=0;
	}else{
		slope[i] = dy / dx;
	}

	}

	int count=1;
	sort(slope, slope + n);

	for(int i=0;i<n-1;i++){
		if(slope[i]!=slope[i+1]){
			count++;
		}
	}

	cout<<count;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    if(dy==0){
    	slope[i]=0;
	}else if(dx==0 && dy!=0){
		slope[i]=99999999;
	}
	else{
		slope[i] = dy / dx;
	}

	}

	int count=1;
	sort(slope, slope + n);

	cout<<endl;
	for(int i=0;i<n;i++){
		cout<<slope[i]<<endl;
	}

	for(int i=0;i<n-1;i++){
		if(slope[i]!=slope[i+1]){
			count++;
		}
	}

	cout<<count;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    if(dy==0){
    	slope[i]=0;
	}else if(dx==0 && dy!=0){
		slope[i]=99999999;
	}
	else{
		slope[i] = dy / dx;
	}

	}

	int count=1;
	sort(slope, slope + n);

	for(int i=0;i<n-1;i++){
		if(slope[i]!=slope[i+1]){
			count++;
		}
	}

	cout<<count;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    if(dy==0 && dx==0){
    	slope[i]=0;
	}else{
		slope[i] = dy / dx;
	}

	}

	int count=1;
	sort(slope, slope + n);

	cout<<endl;
	for(int i=0;i<n;i++){
		cout<<slope[i]<<endl;
	}

	for(int i=0;i<n-1;i++){
		if(slope[i]!=slope[i+1]){
			count++;
		}
	}

	cout<<count;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    slope[i] = dy / dx;

	}

	int count=1;
	sort(slope, slope + n);

	for(int i=0;i<n-1;i++){
		if(slope[i]!=slope[i+1]){
			count++;
		}
	}

	cout<<count;

}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;

	cin>>n;

	double x1, y1;

	cin>>x1;
	cin>>y1;

	double x2[n];
	double y2[n];

	for(int i=0;i<n;i++){
		cin>>x2[i];
		cin>>y2[i];

	}

	double slope[n];

	for(int i=0;i<n;i++){
	double dy = y2[i] - y1;
    double dx = x2[i] - x1;
    if(dy==0){
    	slope[i]=0;
	}
	else{
		slope[i] = dy / dx;
	}

	}

	int count=1;
	sort(slope, slope + n);

	for(int i=0;i<n-1;i++){
		if(slope[i]!=slope[i+1]){
			count++;
		}
	}

	cout<<count;

}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		if(a-x0 == 0) cnt = 1;
		else {
			double k = (double)(b-y0)/(double)(a-x0);
			s.insert(k);
		}
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		double tx = a - x0;
		double ty = b - y0;
		if(tx != 0) cnt = 1;		//´æÔÚÐ±ÂÊÎªÎÞÇîµÄ´¹Ö±Ïß
		else
			s.insert(ty/tx);
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		if(a-x0 == 0) cnt = 1;
		else {
			double k = (double)(b-y0)/(a-x0);
			s.insert(k);
		}
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main() {
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	for(int i = 0;i < n;i++) {
		cin>>a>>b;
		double k = (double)(b-y0)/(a-x0);
		s.insert(k);
	}
	cout<<s.size();
	return 0;
}


#include<cstring>
#include<cstdio>
#include<iostream>
#include<set>

using namespace std;

int main()
{
    int n;
    double xx,yy;
    while(cin>>n>>xx>>yy)
    {
        int p=0;
        set<double>s;
        for(int i=0;i<n;i++)
        {
            double a,b;
            cin>>a>>b;
            if(fabs(a-xx)<=1e-10) p=1;
            else s.insert((b-yy)/(a-xx));
        }
        cout<<s.size()+p<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    double xx,yy;
    while(cin>>n>>xx>>yy)
    {
        int p=0;
        set<double>s;
        for(int i=0;i<n;i++)
        {
            double a,b;
            cin>>a>>b;
            if(fabs(a-xx)<=1e-10) p=1;
            else s.insert((b-yy)/(a-xx));
        }
        cout<<s.size()+p<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		double tx = a - x0;
		double ty = b - y0;
		if(fabs(tx) <= 1e-10) cnt = 1;		//´æÔÚÐ±ÂÊÎªÎÞÇîµÄ´¹Ö±Ïß
		else
			s.insert(ty/tx);
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		double tx = a - x0;
		double ty = b - y0;
		if(tx == 0) cnt = 1;		//´æÔÚÐ±ÂÊÎªÎÞÇîµÄ´¹Ö±Ïß
		else
			s.insert(ty/tx);
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main() {
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0;i < n;i++) {
		cin>>a>>b;
		if(a-x0 == 0) cnt = 1;
		double k = (double)(b-y0)/(a-x0);
		s.insert(k);
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n,x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		double tx = a - x0;
		double ty = b - y0;
		if(abs(tx) <= 1e-10) cnt = 1;		//´æÔÚÐ±ÂÊÎªÎÞÇîµÄ´¹Ö±Ïß
		else
			s.insert(ty/tx);
	}
	cout<<s.size()+cnt;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
set<double> s;		//´æ´¢¼¯ºÏµÄset

int main()
{
	int n;
	double x0,y0,a,b;
	cin>>n>>x0>>y0;
	int cnt = 0;		//cnt´ú±íÊÇ·ñÓÐÖ±ÏßÐ±ÂÊÎªÎÞÇîµÄÇé¿ö
	for(int i = 0; i < n; i++) {
		cin>>a>>b;
		double tx = a - x0;
		double ty = b - y0;
		if(fabs(tx) <= 1e-10) cnt = 1;		//´æÔÚÐ±ÂÊÎªÎÞÇîµÄ´¹Ö±Ïß
		else
			s.insert(ty/tx);
	}
	cout<<s.size()+cnt;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
set <long double> S;
int main(){
    long double n,x0,y0;
    scanf("%llf %llf %llf", &n, &x0, &y0);
    long double x,y;
    for(int i=0; i<n; i++){
        scanf("%llf %llf", &x, &y);
        long double sl;
        if(y==y0)
        sl=100000000000000;
        else
        sl=((x-x0)/(y-y0));
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set <double> S;
int main(){
    double n,x0,y0;
    scanf("%lf %lf %lf", &n, &x0, &y0);
    double x,y;
    for(int i=0; i<int(n); i++){
        scanf("%lf %lf", &x, &y);
        double sl;
        if(y==y0)
        sl=100000000;
        else
        sl=((x-x0)/(y-y0));
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set <double> S;
int main(){
    double n,x0,y0;
    scanf("%lf %lf %lf", &n, &x0, &y0);
    double x,y;
    for(int i=0; i<int(n); i++){
        scanf("%lf %lf", &x, &y);
        double sl=((x-x0)/y-y0);
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set <long double> S;
int main(){
    long double n,x0,y0;
    scanf("%llf %llf %llf", &n, &x0, &y0);
    long double x,y;
    for(int i=0; i<int(n); i++){
        scanf("%llf %llf", &x, &y);
        long double sl;
        if(y==y0)
        sl=100000000000000;
        else
        sl=((x-x0)/(y-y0));
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    long n,sum=0; double x,y,a,b,k=0; set<double>s;cin>>n>>x>>y;
    for(long i=0;i<n;i++){cin>>a>>b;if(y!=b) s.insert((x-a)/(y-b)); else k=1;}
    cout<<s.size()+k;
}


#include<bits/stdc++.h>
using namespace std;
set <double> S;
int main(){
    double n,x0,y0;
    scanf("%lf %lf %lf", &n, &x0, &y0);
    double x,y;
    for(int i=0; i<int(n); i++){
        scanf("%lf %lf", &x, &y);
        double sl=((x-x0)/(y-y0));
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set <long double> S;
int main(){
    long double n,x0,y0;
    scanf("%llf %llf %llf", &n, &x0, &y0);
    long double x,y;
    for(int i=0; i<(long long)n; i++){
        scanf("%llf %llf", &x, &y);
        long double sl;
        if(y==y0)
        sl=100000000000000;
        else
        sl=((x-x0)/(y-y0));
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set <double> S;
int main(){
    double n,x0,y0;
    scanf("%lf %lf %lf", &n, &x0, &y0);
    double x,y;
    for(int i=0; i<int(n); i++){
        scanf("%lf %lf", &x, &y);
        if(y==y0)
        double sl=100000000;
        else
        double sl=((x-x0)/(y-y0));
        S.insert(sl);
    }
    printf("%d", S.size());
    return 0;
}


#include <iostream>
#include <map>
#include <set>
using namespace std;
long n,i,k,x,y,a,b,x1;
set <double> m;
set <double> ::iterator it;
int main() {
  cin>>n>>x>>y;
  for (i=0; i<n; i++){
    cin>>a>>b;
    if (b==y) x1=1;
	else m.insert((double)(x-a)/(double)(y-b));
  }
  cout<<m.size()+x1<<endl;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
const ll INF64 =3e18;
void smxl(ll &a, ll b){if (a < b)a=b;}
void smnl(ll &a, ll b){if (a > b)a=b;}
void adsl(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void misl(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
void smx(ll &a, ll b){if (a < b)a=b;}
void smn(ll &a, ll b){if (a > b)a=b;}
void ads(ll &a, ll b){a += b;if (a >= mod)a -= mod;}
void mis(ll &a, ll b){a -= b;if (a >= mod)a -= mod; if (a < 0)a += mod;}
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
long long C(int n, int m){ll ret=1;for(int i=1;i<=m;i++){ret*=(n-i+1);ret/=i;}return ret;}
long long overbinp(long long a, int b){long long res = 1;while (b){if (b & 1){if (res < INF64 / a) res *= a;else return INF64;}if (b > 1){if (a < INF64 / a) a *= a;else return INF64;}b >>= 1;}return res;}
/*const int FMAXN = 1000 * 1000 + 10;int fen[FMAXN];void add(int x, int val){for (int i = x + 1; i < MAXN; i += i & (-i)) fen[i] += val;}int get(int x){int ans = 0;for (int i = x; i > 0; i -= i & (-i)) ans += fen[i];return ans;}int sum(int x, int y){return get(y) - get(x);}*/
/*int distfloor(int n){int sum;int la;for (int i = 1; i <= n; i = la+1){la = n/(n/i);sum++;show(n/i);}return sum;}*/
//int pointsCoveredBySegment(pi a, pi b){return(gcd((int)abs(a.F-b.F),(int)abs(a.S-b.S))+1);}
//segment inters
/*struct seg{int x1, y1, x2, y2;seg(){};};
struct line{long long Al, Bl, Cl;line(){};line(seg a){Al = a.y1 - a.y2;Bl = a.x2 - a.x1;Cl = -Al * a.x1 - Bl * a.y1;};};
int get(seg a){int dx = a.x1 - a.x2;int dy = a.y1 - a.y2;return __gcd(abs(dx), abs(dy)) + 1;}
long long det(long long a, long long b, long long c, long long d){return a * d - b * c;}
bool in(int x, int l, int r){if (l > r) swap(l, r);return (l <= x && x <= r);}
bool inter(seg a, seg b, int& x, int& y){line l1(a), l2(b);long long dx = det(l1.Cl, l1.Bl, l2.Cl, l2.Bl);long long dy = det(l1.Al, l1.Cl, l2.Al, l2.Cl);long long d = det(l1.Al, l1.Bl, l2.Al, l2.Bl);if (d == 0)return false;if (dx % d != 0 || dy % d != 0)return false;x = -dx / d;y = -dy / d;if (!in(x, a.x1, a.x2) || !in(y, a.y1, a.y2))return false;if (!in(x, b.x1, b.x2) || !in(y, b.y1, b.y2))return false;return true;}*/

int reach[21];
int used[21];
vi adj[1000010];
vi radj[1000010];
void dfs(int n)
{
	used[n] = 1;
	for (int z : adj[n])
		if (used[z] == 0)
			dfs(z);

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin >> n >> m;
	vi sinks;
	vi srcs;
	REP(i,0,m)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		adj[a].PB(b);
		radj[b].PB(a);
	}
	REP(i,0,n)
	{
		if (radj[i].Z == 0)
			srcs.PB(i);
		if (adj[i].Z == 0)
			sinks.PB(i);
	}
	REP(i,0,srcs.Z)
	{
		memset(used,0,sizeof(used));
		dfs(srcs[i]);
		REP(j,0,sinks.Z)
			if (used[sinks[j]] == 1)
				reach[srcs[i]] ^= (1<<j);
	}
	int cnt = srcs.Z;
	bool ok =true;
	for (int msk = 0; msk < (1<<cnt) ; msk++)
	{
		int res = 0;
		REP(i,0,cnt)
			if (msk &(1<<i))
				//REP(j,0,cnt)
				//	if (reach[i]&(1<<j))
						res |= reach[srcs[i]];
		int s1 = __builtin_popcount(msk);
		int s2 = __builtin_popcount(res);
		if (s2< s1 || s2 == s1 && s1 != 0 && s1 != cnt)
			ok = false;
	}
	cout << (ok?"YES":"NO");
}


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

int n, m, num = 0, fst[1000010], ideg[1000010], odeg[1000010], sinkid[1000010];
struct edge
{
    int x, y, n;
} e[1000010];
bool v[1000010];
vector<int> source;

void ins(int x, int y)
{
    e[++num] = {x, y, fst[x]};
    fst[x] = num;
}
void dfs(int x, int &s)
{
    if (v[x]) return;
    v[x] = 1;
    if (odeg[x] == 0) s |= 1 << sinkid[x];
    for (int i = fst[x]; i; i = e[i].n)
        dfs(e[i].y, s);
}
int count(int s)
{
    int ans = 0;
    while (s)
    {
        ans += s & 1;
        s >>= 1;
    }
    return ans;
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        ins(x, y);
        ideg[y]++;
        odeg[x]++;
    }
    memset(sinkid, -1, sizeof(sinkid));
    for (int i = 1, nn = 0; i <= n; i++) if (odeg[i] == 0) sinkid[i] = nn++;
    for (int i = 1; i <= n; i++)
        if (ideg[i] == 0)
        {
            memset(v, 0, sizeof(v));
            source.push_back(0);
            dfs(i, source.back());
        }/*
    for (int x : source) printf("%d ", x);
    puts("");*/
    for (int i = 1; i < (1 << source.size()) - 1; i++)
    {
        int s = 0;
        for (int j = 0; j < source.size(); j++)
            if (i & (1 << j))
                s |= source[j];
        if (count(i) >= count(s))
        {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int num[N], sz[N], w[N], used[N];
bool g[N];
int z = 0;

void dfs(int node, int from) {
	used[node] = z;
	if (num[node] != -1) {
		w[1 << from] |= 1 << num[node];
		return;
	}
	for (int to : v[node]) {
		if (used[to] != z) {
			dfs(to, from);
		}
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	fill(num, num + n, -1);

	for (int i = 0, j = 0; i < n; i++) {
		if (v[i].empty()) {
			num[i] = j++;
		}
	}

	int k = 0;
	for (int i = 0; i < n; i++) {
		if (!g[i]) {
			z++;
			dfs(i, k++);
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int sz[N], w[N], t[N];
bool g[N], used[N];
int k = 0;

void dfs(int node) {
	used[node] = 1;
	if (v[node].empty()) {
		t[node] |= 1 << k;
		k++;
		return;
	}
	for (int to : v[node]) {
		if (!used[to]) {
			dfs(to);
		}
		t[node] |= t[to];
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	for (int i = 0; i < n; i++) {
		if (!used[i])
			dfs(i);
	}

	for (int i = 0, j = 0; i < n; i++) {
		if (!g[i]) {
			w[1 << j] = t[i];
			j++;
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int num[N], sz[N], w[N];
bool g[N], used[N];
int z = 0;

void dfs(int node, int from) {
	used[node] = 1;
	if (v[node].empty()) {
		w[1 << from] |= 1 << num[node];
		return;
	}
	for (int to : v[node]) {
		if (!used[to]) {
			dfs(to, from);
		}
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	for (int i = 0, j = 0; i < n; i++) {
		if (v[i].empty()) {
			num[i] = j++;
		}
	}

	int k = 0;
	for (int i = 0; i < n; i++) {
		if (!g[i]) {
			fill(used, used + n, 0);
			z++;
			dfs(i, k++);
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1 << 20;
vector<int> v[N];
int sz[N], w[N], t[N];
bool g[N], used[N];
int k = 0;

void dfs(int node) {
	used[node] = 1;
	if (v[node].empty()) {
		t[node] |= 1 << k;
		k++;
		return;
	}
	for (int to : v[node]) {
		if (!used[to]) {
			dfs(to);
		}
		t[node] |= t[to];
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	for (int i = 0; i < n; i++) {
		if (!used[i])
			dfs(i);
	}

	for (int i = 0, j = 0; i < n; i++) {
		if (!g[i]) {
			w[1 << j] = t[i];
			j++;
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int sz[N], w[N], t[K];
bool g[N], used[N];
int z = 0;

void dfs(int node) {
	used[node] = 1;
	for (int to : v[node]) {
		if (!used[to]) {
			dfs(to);
		}
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	int k = 0;
	for (int i = 0; i < n; i++) {
		if (v[i].empty()) {
			t[k++] = i;
		}
	}

	for (int i = 0, j = 0; i < n; i++) {
		if (!g[i]) {
			memset(used, 0, sizeof(used));
			dfs(i);
			for (int h = 0; h < k; h++) {
				if (used[t[h]])
					w[j] |= 1 << h;
			}
			j++;
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int sz[N], w[N], t[K];
bool g[N], used[N];
int z = 0;

void dfs(int node) {
	used[node] = 1;
	for (int to : v[node]) {
		if (!used[to]) {
			dfs(to);
		}
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	int k = 0;
	for (int i = 0; i < n; i++) {
		if (v[i].empty()) {
			t[k++] = i;
		}
	}

	for (int i = 0, j = 0; i < n; i++) {
		if (!g[i]) {
			memset(used, 0, sizeof(used));
			dfs(i);
			for (int h = 0; h < k; h++) {
				if (used[t[h]])
					w[i] |= 1 << h;
			}
			j++;
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
#pragma warning(disable : 4996)

const int N = 1e6 + 5, K = 20;
vector<int> v[N];
int num[N], sz[N], w[N], t[N];
bool g[N], used[N];
int z = 0;

void dfs(int node) {
	used[node] = 1;
	if (v[node].empty()) {
		t[node] |= 1 << num[node];
		return;
	}
	for (int to : v[node]) {
		if (!used[to]) {
			dfs(to);
			t[node] |= t[to];
		}
	}
}

signed main() {
#ifdef HOME
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[a].push_back(b);
		g[b] = 1;
	}

	for (int i = 0, j = 0; i < n; i++) {
		if (v[i].empty()) {
			num[i] = j++;
		}
	}

	int k = 0;
	for (int i = 0; i < n; i++) {
		if (!used[i])
			dfs(i);
	}

	for (int i = 0; i < n; i++) {
		if (!g[i]) {
			w[1 << k] = t[i];
			k++;
		}
	}

	for (int i = 0; i < k; i++) {
		sz[1 << i] = 1;
	}

	for (int i = 1; i < (1 << k); i++) {
		sz[i] = sz[i & -i] + sz[i ^ (i & -i)];
	}

	for (int i = 1; i < (1 << k) - 1; i++) {
		w[i] = w[i & -i] | w[i ^ (i & -i)];
		if (sz[w[i]] == sz[i]) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";

	return 0;
}


//#pragma GCC optimize("O3")
//#pragma GCC target("arch=corei7-avx")
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
# include <sys/time.h>
# include <sys/resource.h>
#endif

/*** TEMPLATE CODE STARTS HERE ***/

#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795028841971693993751
#endif

using namespace std;

typedef vector<string> vs;
typedef long long ll;
typedef complex<double> pnt;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define RA(x) begin(x), end(x)
#define FE(i, x) for (auto i = begin(x); i != end(x); ++i)
#define SZ(x) ((ll) (x).size())

template<class T>
void splitstr(const string &s, vector<T> &out)
{
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

static void redirect(int argc, const char **argv)
{
#ifndef ONLINE_JUDGE
    struct rlimit rlim;
    getrlimit(RLIMIT_STACK, &rlim);
    rlim.rlim_cur = 256 * 1024 * 1024;
    setrlimit(RLIMIT_STACK, &rlim);
#ifndef __SANITIZE_ADDRESS__
    getrlimit(RLIMIT_DATA, &rlim);
    rlim.rlim_cur = 256 * 1024 * 1024;
    setrlimit(RLIMIT_DATA, &rlim);
#endif
#endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    if (argc > 1)
    {
        static filebuf f;
        f.open(argv[1], ios::in);
        cin.rdbuf(&f);
        if (!cin)
        {
            cerr << "Failed to open '" << argv[1] << "'" << endl;
            exit(1);
        }
    }

    if (argc > 2)
    {
        static filebuf f;
        f.open(argv[2], ios::out | ios::trunc);
        cout.rdbuf(&f);
        if (!cout)
        {
            cerr << "Failed to open '" << argv[2] << "'" << endl;
        }
    }
}

/*** TEMPLATE CODE ENDS HERE */

enum State
{
    NEW, ACTIVE, DONE
};

static void dfs(int cur, const vector<vi> &edges, vector<State> &state, vi &reach)
{
    state[cur] = ACTIVE;
    for (int y : edges[cur])
    {
        if (state[y] == NEW)
            dfs(y, edges, state, reach);
        reach[cur] |= reach[y];
    }
    state[cur] = DONE;
}

int main(int argc, const char **argv)
{
    redirect(argc, argv);
    int N, M;
    cin >> N >> M;
    vector<vi> edges(N);
    vi indeg(N);
    vi outdeg(N);
    for (int i = 0; i < M; i++)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edges[u].push_back(v);
        outdeg[u]++;
        indeg[v]++;
    }
    vi sources, sinks;
    for (int i = 0; i < N; i++)
    {
        if (indeg[i] == 0)
            sources.push_back(i);
        if (outdeg[i] == 0)
            sinks.push_back(i);
    }
    int S = SZ(sources);
    assert(S == SZ(sinks));

    vector<State> state(N, NEW);
    vi fullreach(N);
    vi reach(S);
    for (int i = 0; i < S; i++)
        fullreach[sinks[i]] = 1 << i;
    for (int i = 0; i < S; i++)
    {
        dfs(sources[i], edges, state, fullreach);
        reach[i] = fullreach[sources[i]];
    }

    for (int m = 1; m < (1 << S) - 1; m++)
    {
        int r = 0;
        for (int i = 0; i < S; i++)
            if (m & (1 << i))
                r |= reach[i];
        if (__builtin_popcount(r) <= __builtin_popcount(m))
        {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";

    return 0;
}


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

int N, M;
const int MAX = 1e6;
vector<int> edges[MAX];
int indeg[MAX];
vector<int> source;
map<int, int> sink;
int reachable[20];
const int BITMAX = 1<<20;
int dp[BITMAX];

void dfs(int start, int i){
    if(sink.count(i)){
        reachable[start] |= sink[i];
    }else{
        for(auto j : edges[i]) dfs(start, j);
    }
}

int main(){
    int i, j, k;
    cin >> N >> M;
    for(i=0; i<M; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        edges[x-1].push_back(y-1);
        indeg[y-1]++;
    }
    int num = 1;
    for(i=0; i<N; i++){
        if(indeg[i]==0) source.push_back(i);
        if(edges[i].size()==0){
            sink[i] = num;
            num *= 2;
        }
    }

    int sz = source.size();
    for(i=0; i<sz; i++) dfs(i, source[i]);

    int bitmax = 1<<sz;
    for(i=1; i<bitmax; i++){
        bool updated = false;
        int in = 0;
        for(j=0; j<sz; j++){
            if((i>>j) & 1){
                in++;
                if(!updated){
                    dp[i] = dp[i-(1<<j)] | reachable[j];
                    updated = true;
                }
            }
        }
        int out = 0;
        for(j=0; j<sz; j++){
            if((dp[i]>>j) & 1) out++;
        }
        if(in >= out && in < sz){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <deque>
#include <string.h>
#include <sstream>
#include <bitset>
#include <math.h>
#include <assert.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 0.000000001
#define INF 5000000000000000000
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N, M, inDeg [1000010], outDeg [1000010], reachable [25];
vector<int> adjacency [1000010], sources;
unordered_map<int, int> sinks;

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        adjacency[a].pb(b);
        outDeg[a]++; inDeg[b]++;
    }
    for(int i = 1, id = 0; i <= N; i++){
        if(inDeg[i] == 0) sources.pb(i);
        if(outDeg[i] == 0) sinks[i] = id++;
    }
    for(int i = 0; i < sources.size(); i++){
        queue<int> q; q.push(sources[i]);
        while(q.size() > 0){
            int now = q.front(); q.pop();
            if(outDeg[now] == 0) reachable[i] |= (1<<sinks[now]);
            for(int nexty : adjacency[now]) q.push(nexty);
        }
    }
    for(int mask = 1; mask < (1<<sources.size())-1; mask++){
        int reached = 0;
        for(int i = 0; i < sources.size(); i++)
            if(mask&(1<<i))
                reached |= reachable[i];
        int sourcesUsed = __builtin_popcount(mask), sinksReached = __builtin_popcount(reached);
        if(sinksReached <= sourcesUsed){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <deque>
#include <string.h>
#include <sstream>
#include <bitset>
#include <math.h>
#include <assert.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 0.000000001
#define INF 5000000000000000000
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N, M, inDeg [100010], outDeg [100010], reachable [25];
vector<int> adjacency [100010], sources;
unordered_map<int, int> sinks;

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        adjacency[a].pb(b);
        outDeg[a]++; inDeg[b]++;
    }
    for(int i = 1, id = 0; i <= N; i++){
        if(inDeg[i] == 0) sources.pb(i);
        if(outDeg[i] == 0) sinks[i] = id++;
    }
    for(int i = 0; i < sources.size(); i++){
        queue<int> q; q.push(sources[i]);
        while(q.size() > 0){
            int now = q.front(); q.pop();
            if(outDeg[now] == 0) reachable[i] |= (1<<sinks[now]);
            for(int nexty : adjacency[now]) q.push(nexty);
        }
    }
    for(int mask = 1; mask < (1<<sources.size())-1; mask++){
        int reached = 0;
        for(int i = 0; i < sources.size(); i++)
            if(mask&(1<<i))
                reached |= reachable[i];
        int sourcesUsed = __builtin_popcount(mask), sinksReached = __builtin_popcount(reached);
        if(sinksReached <= sourcesUsed){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


#include<bits/stdc++.h>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 1e6+5;
const int K = 25;
const int L = (1<<20)+5;

int n,m;
struct edge{
	int x,nxt;
}e[N];
int h[N],tot;

void inse(int x,int y){e[++tot].x=y;e[tot].nxt=h[x];h[x]=tot;}

int f[K],g[K];
int can[K];
int in[N],out[N];
int id[N],k1,k2;
int vis[N],tim;
int st;

void dfs(int x){
	vis[x]=tim;
	if (!out[x])can[id[x]]|=(1<<(st-1));
	for(int p=h[x];p;p=e[p].nxt)
	if (vis[e[p].x]<tim)dfs(e[p].x);
}

int cnt[L];

int main(){
	n=get();m=get();
	fo(i,1,m){
		int x=get(),y=get();
		out[x]++,in[y]++;
		inse(x,y);
	}
	fo(i,1,n)if (!out[i])g[id[i]=++k2]=i;
	fo(i,1,n)if (!in[i])f[id[i]=++k1]=i;
	int k=k1;
	fo(i,1,k){
		int x=f[i];
		tim++;
		st=i;
		dfs(x);
	}
	bool ans=1;
	fo(i,1,(1<<k)-1)cnt[i]=cnt[i-(i&-i)]+1;
	fo(i,1,(1<<k)-2){
		int all=0;
		fo(x,1,k)if ((i&(1<<(x-1)))>0)all|=can[x];
		if(cnt[all]<=cnt[i]){ans=0;break;}
	}
	if (ans)printf("YES\n");else printf("NO\n");
	return 0;
}


//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(int x = 1 ; x <= (int)y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef complex<int> point;
const int nmax = 1000005;
const ll linf = 1e18;
const ll mod = 998244353;
const int inf = 1e9;

int n, m;
vec <int > g[nmax];
int in[nmax], out[nmax];
vec <int > a[nmax];

void dfs(int nod , int root){
    if(out[nod] == 0){
        a[root].pb(nod);
    }
    for(int j : g[nod]){
        dfs(j,root);
    }
}

int main(){
	fast
	cin >> n >> m;
	forn(i,m){
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        in[b] ++;
        out[a] ++;
	}
	vec < int > s , f;

	forn(i,n){
        if(in[i] == 0){
            s.pb(i);
        }
        if(out[i] == 0){
            f.pb(i);
        }
	}
	for(int i = 0 ; i < s.size() ; i++){
        dfs(s[i],s[i]);
	}
	int k = s.size();
	for(int i = 1 ; i <  (1<<k) - 1; i++){
        set < int > valid;
        for(int j = 0 ; j < k; j ++){
            if( i & (1<<j)){
                for(int asd : a[s[j]]){
                    valid.insert(asd);
                }
            }
        }
        if( valid.size() <= __builtin_popcount(i)){
            cout << "NO\n";
            return 0;
        }
	}
	cout << "YES\n";
	return 0;
}


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

#define MP make_pair
#define FF first
#define SS second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pie;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const ll LINF = 4e18;
const ll delta = 96181;

const int N = 1e6 + 20;
vector<int> G[N], sinks, srcs;
int n, m, in[N], out[N], f[N];
bool visited[N];

void dfs(int v) {
	visited[v] = 1;
	for (int u : G[v])
		if (!visited[u])
			dfs(u);
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0, v, u; i < m; i++) {
		cin >> v >> u;
		G[v].push_back(u);
		out[v]++; in[u]++;
	}
	for (int i = 1; i <= n; i++) {
		if (in[i] == 0)
			srcs.push_back(i);
		if (out[i] == 0)
			sinks.push_back(i);
	}
	for (int i = 0; i < srcs.size(); i++) {
		int v = srcs[i];
		memset(visited, 0, sizeof visited);
		dfs(v);
		for (int j = 0; j < sinks.size(); j++)
			if (visited[sinks[j]])
				f[i] += 1 << j;
	}
	for (int mask = 1; mask < (1 << (int)srcs.size()) - 1; mask++) {
		int res = 0;
		for (int i = 0; i < srcs.size(); i++)
			if (mask & (1 << i))
				res = res | f[i];
		if (__builtin_popcount(res) <= __builtin_popcount(mask))
			return cout << "NO" << endl, 0;
	}
	cout << "YES" << endl;
}


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

int input[1000005];
int output[1000005];
bool reachable[21][1000005];
vector<int> tail;
// use an array will be much faster then map
std::vector<int> g[1000005];

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    int from, to;
    scanf("%d %d", &n, &m);
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    memset(reachable, 0 , sizeof(reachable));
    tail.clear();
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &from, &to);
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    set<int> s;
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.insert(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[1000005];
int output[1000005];
bool reachable[21][1000005];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        set<int> s;
        s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.insert(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[100005];
int output[100005];
bool reachable[21][100005];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        vector<int> s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.push_back(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[100005];
int output[100005];
bool reachable[21][100005];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        set<int> s;
        s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.insert(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[1000005];
int output[1000005];
bool reachable[21][1000005];
vector<int> tail;
std::vector<int> g[1000005];

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    memset(reachable, 0 , sizeof(reachable));
    tail.clear();
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    set<int> s;
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.insert(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[100001];
int output[100001];
bool reachable[21][100001];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[from]++;
        output[to]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    for(int i = 1; i <= (1 << sourceNumber) - 1; i ++)
    {
        vector<int> s;
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == 1)
                    {
                        s.push_back(x);
                    }
                }
                if(cnt <= s.size())
                {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[1000005];
int output[1000005];
bool reachable[21][1000005];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    set<int> s;
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.insert(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[1000005];
int output[1000005];
bool reachable[21][1000005];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    memset(reachable, 0 , sizeof(reachable));
    g.clear();
    tail.clear();
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    set<int> s;
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        s.clear();
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.insert(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

int input[100005];
int output[100005];
bool reachable[21][100005];
vector<int> tail;
std::map<int, std::vector<int> >g;

void dfs(int sourceNumber, int source)
{
    reachable[sourceNumber][source] = true;
    for(auto x:g[source])
    {
        if(reachable[sourceNumber][x] == false)
        {
            dfs(sourceNumber, x);
        }
    }
}

int main(int argc, char *argv[])
{
    int n,m;
    cin >> n >> m;
    memset(input,0, sizeof(input));
    memset(output,0, sizeof(output));
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
        input[to]++;
        output[from]++;
    }
    int sourceNumber = 0;
    for (int i = 1; i <= n; ++i) {
        if(input[i] == 0)
        {
            dfs(sourceNumber, i);
            sourceNumber++;
        }
        if(output[i] == 0)
        {
            tail.push_back(i);
        }
    }
    for(int i = 1; i < (1 << sourceNumber) - 1; i ++)
    {
        vector<int> s;
        int cnt = 0;
        for (int j = 0; j < sourceNumber; ++j) {
            if(i & ( 1<<j))
            {
                //chech this source
                cnt++;
                for(auto x:tail)
                {
                    if(reachable[j][x] == true)
                    {
                        s.push_back(x);
                    }
                }
            }
        }
        if(s.size() <= cnt)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=25;
int n,m;
int in[N],out[N];
int source[M],tot1;
int pos[N],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	if(out[s]==0) S|=1<<pos[s];
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<pos[v];
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) pos[i]=tot2++;
	}
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=1000005;
int n,m;
int in[N],out[N];
int source[M],tot1;
int pos[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	if(out[s]==0) S|=1<<pos[s];
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<pos[v];
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) pos[i]=tot2++;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"pos:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<pos[i]<<" ";cerr<<endl;
	assert(tot1==tot2);
	assert(tot1<=21);
	assert(tot2<=21);
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
//	cerr<<"state:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<state[i]<<" ";cerr<<endl;
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=1000005;
int n,m;
int in[N],out[N];
int source[M],tot1;
int sink[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	if(out[s]==0) S|=1<<s;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<v;
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) sink[tot2++]=i;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"sink:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<sink[i]<<" ";cerr<<endl;
	assert(tot1<=21);
	assert(tot2<=21);
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=25;
int n,m;
int in[N],out[N];
int source[M],tot1;
int pos[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	if(out[s]==0) S|=1<<pos[s];
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<pos[v];
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) pos[i]=tot2++;
	}
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=1000005;
int n,m;
int in[N],out[N];
int source[M],tot1;
int sink[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	if(out[s]==0) S|=1<<s;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<v;
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) sink[tot2++]=i;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"sink:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<sink[i]<<" ";cerr<<endl;
	assert(tot1==tot2);
	assert(tot1<=21);
	assert(tot2<=21);
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=25;
int n,m;
int in[N],out[N];
int source[M],tot1;
int sink[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	if(out[s]==0) S|=1<<s;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<v;
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) sink[tot2++]=i;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"sink:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<sink[i]<<" ";cerr<<endl;
	assert(tot1<=21);
	assert(tot2<=21);
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=25;
int n,m;
int in[N],out[N];
int source[M],tot1;
int sink[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<v;
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) sink[tot2++]=i;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"sink:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<sink[i]<<" ";cerr<<endl;
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=25;
int n,m;
int in[N],out[N];
int source[M],tot1;
int sink[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<v;
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) sink[tot2++]=i;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"sink:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<sink[i]<<" ";cerr<<endl;
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cassert>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int N=1000005,M=25;
int n,m;
int in[N],out[N];
int source[M],tot1;
int sink[M],tot2;
int state[M];
vector<int>G[N];
int bfs(int s)
{
	static bool vis[N];
	memset(vis,false,sizeof(vis));
	queue<int>q;
	vis[s]=true;
	q.emplace(s);
	int S=0;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int v:G[u])
		{
			if(vis[v]) continue;
			if(out[v]==0) S|=1<<v;
			vis[v]=true;
			q.emplace(v);
		}
	}
	return S;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		G[x].emplace_back(y);
		out[x]++,in[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(in[i]==0) source[tot1++]=i;
		if(out[i]==0) sink[tot2++]=i;
	}
//	cerr<<"source:\n";
//	for(int i=0;i<tot1;i++)
//		cerr<<source[i]<<" ";cerr<<endl;
//	cerr<<"sink:\n";
//	for(int i=0;i<tot2;i++)
//		cerr<<sink[i]<<" ";cerr<<endl;
	assert(tot1<=21);
	assert(tot2<=21);
	for(int i=0;i<tot1;i++)
		state[i]=bfs(source[i]);
	for(int S=1;S<(1<<tot1)-1;S++)
	{
		int to=0;
		for(int i=0;i<tot1;i++)
			if(S&(1<<i)) to|=state[i];
		if(__builtin_popcount(to)<=__builtin_popcount(S))
		{
//			cerr<<"now"<<S<<"\n";
//			for(int i=0;i<tot1;i++)
//				if(S&(1<<i)) cerr<<i<<" ";cerr<<endl;
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}


#include <iostream>
#include <bitset>
#include <vector>
using namespace std;

const int maxn = 100001;
vector<int> g[maxn];
int din[maxn];
int dout[maxn];

vector<int> istok;
vector<int> stock;

vector<bitset<20> > maskin;

int was[maxn];

void add(int a, int b) {
	g[a].push_back(b);
	dout[a] += 1;
	din[b] += 1;
}

void dfs(int v) {
	was[v] = 1;
	for(auto x : g[v]) {
		if(!was[x]) dfs(x);
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	int m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		add(a, b);
	}

	for(int i = 1; i < n + 1; i++) {
		if(dout[i] == 0) {
			stock.push_back(i);
		}
		if(din[i] == 0) {
			istok.push_back(i);
		}
	}

	for(int i = 0; i < istok.size(); i++) {
		fill(was, was + maxn, 0);
		dfs(istok[i]);
		bitset<20> tmp;
		for(int i = 0; i < stock.size(); i++) {
			int x = stock[i];
			if(was[x] == 1) {
				tmp[i] = 1;
			}
		}

		maskin.push_back(tmp);
	}

	int maxmask = 1 << (int)maskin.size();

	bool ok = 1;

	for(int mask = 1; mask < maxmask - 1; mask++) {
		bitset<20> tmp;
		bitset<20> tmp2(mask);
		for(int i = 0; i < maskin.size(); i++ ) {
			if((1 << i) & mask) tmp |= maskin[i];
		}
		if(tmp2.count() == tmp.count()) {
			ok = 0;
			break;
		}
	}

	if(ok == 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


#include <iostream>
#include <bitset>
#include <vector>
using namespace std;

const int maxn = 1000001;
vector<int> g[maxn];
int din[maxn];
int dout[maxn];

vector<int> istok;
vector<int> stock;

vector<bitset<20> > maskin;

int was[maxn];

void add(int a, int b) {
	g[a].push_back(b);
	dout[a] += 1;
	din[b] += 1;
}

void dfs(int v) {
	was[v] = 1;
	for(auto x : g[v]) {
		if(!was[x]) dfs(x);
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	int m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		add(a, b);
	}

	for(int i = 1; i < n + 1; i++) {
		if(dout[i] == 0) {
			stock.push_back(i);
		}
		if(din[i] == 0) {
			istok.push_back(i);
		}
	}

	for(int i = 0; i < istok.size(); i++) {
		fill(was, was + maxn, 0);
		dfs(istok[i]);
		bitset<20> tmp;
		for(int i = 0; i < stock.size(); i++) {
			int x = stock[i];
			if(was[x] == 1) {
				tmp[i] = 1;
			}
		}

		maskin.push_back(tmp);
	}

	int maxmask = 1 << (int)maskin.size();

	bool ok = 1;

	for(int mask = 1; mask < maxmask - 1; mask++) {
		bitset<20> tmp;
		bitset<20> tmp2(mask);
		for(int i = 0; i < maskin.size(); i++ ) {
			if((1 << i) & mask) tmp |= maskin[i];
		}
		if(tmp2.count() == tmp.count()) {
			ok = 0;
			break;
		}
	}

	if(ok == 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N	1000000
#define K	20

int *ej[N], eo[N];

void append(int i, int j) {
	int o = eo[i]++;

	if (o >= 2 && (o & o - 1) == 0)
		ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
	ej[i][o] = j;
}

int bb[N], k;

void dfs(int i) {
	int o;

	if (bb[i])
		return;
	if (eo[i] == 0)
		bb[i] = 1 << k++;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		dfs(j), bb[i] |= bb[j];
	}
}

int main() {
	static char source[N];
	static int bb_[1 << K], cnt[1 << K];
	int n, m, k, i, j, b;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		ej[i] = (int *) malloc(2 * sizeof *ej[i]);
	memset(source, 1, n * sizeof *source);
	while (m--) {
		scanf("%d%d", &i, &j), i--, j--;
		append(i, j);
		source[j] = 0;
	}
	k = 0;
	for (i = 0; i < n; i++)
		if (source[i])
			dfs(i), bb_[1 << k++] = bb[i];
	for (b = 0; b < 1 << k; b++) {
		bb_[b] = bb_[b & b - 1] | bb_[b & -b];
		cnt[b] = cnt[b & b - 1] + 1;
	}
	for (b = 1; b < (1 << k) - 1; b++)
		if (cnt[bb_[b]] == cnt[b]) {
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
}


#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int color[40], deg[40], ideg[1000000], odeg[1000000];
bool visited[1000000];
vector<int> adj[1000000], in, on;

void dfs(int c)
{
	visited[c] = true;
	for (auto n : adj[c]) {
		if (!visited[n]) dfs(n);
	}
}

int find_(int a)
{
	if (a == color[a]) return a;
	return color[a] = find_(color[a]);
}

void union_(int a, int b)
{
	a = find_(a);
	b = find_(b);
	color[a] = color[b] = min(a, b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M;
	for (cin >> N >> M; M; M--) {
		int a, b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		odeg[a]++;
		ideg[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (ideg[i] == 0) in.push_back(i);
		if (odeg[i] == 0) on.push_back(i);
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		color[i] = i;
	}
	for (int i = 0; i < in.size(); i++) {
		memset(visited, 0, sizeof(visited));
		dfs(in[i]);
		for (int j = 0; j < on.size(); j++) {
			if (visited[on[j]]) {
				union_(i, j + in.size());
				deg[i]++;
				deg[j + in.size()]++;
			}
		}
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		if (find_(i) || deg[i] < 2) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}


#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int color[40], deg[40], ideg[1000000], odeg[1000000];
bool visited[1000000], ovisited[20];
vector<int> adj[1000000], in, on, sadj[20];

void dfs(int c)
{
	visited[c] = true;
	for (auto n : adj[c]) {
		if (!visited[n]) dfs(n);
	}
}

int find_(int a)
{
	if (a == color[a]) return a;
	return color[a] = find_(color[a]);
}

void union_(int a, int b)
{
	a = find_(a);
	b = find_(b);
	color[a] = color[b] = min(a, b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M;
	for (cin >> N >> M; M; M--) {
		int a, b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		odeg[a]++;
		ideg[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (ideg[i] == 0) in.push_back(i);
		if (odeg[i] == 0) on.push_back(i);
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		color[i] = i;
	}
	for (int i = 0; i < in.size(); i++) {
		memset(visited, 0, sizeof(visited));
		dfs(in[i]);
		for (int j = 0; j < on.size(); j++) {
			if (visited[on[j]]) {
			    sadj[i].push_back(j);
			}
		}
	}
	for (int i = 1; i < (1 << in.size()); i++) {
	    int icnt = 0, ocnt = 0;
	    memset(ovisited, 0, sizeof(ovisited));
	    for (int j = 0; j < in.size(); j++) {
	        if(i & (1 << j)) {
	            cnt++;
	            for(auto n: sadj[j]) {
	                ovisited[n] = true;
	            }
	        }
	    }
	    for (int j = 0; j < on.size(); j++) {
	        ocnt += ovisited[j];
	    }
	    if(icnt > ocnt) {
	        cout << "NO\n";
	        return 0;
	    }
	}
	cout << "YES\n";
	return 0;
}


#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int color[40], ideg[1000000], odeg[1000000];
bool visited[1000000];
vector<int> adj[1000000], in, on;

void dfs(int c)
{
	visited[c] = true;
	for (auto n : adj[c]) {
		if (!visited[n]) dfs(n);
	}
}

int find_(int a)
{
	if (a == color[a]) return a;
	return color[a] = find_(color[a]);
}

void union_(int a, int b)
{
	a = find_(a);
	b = find_(b);
	color[a] = color[b] = min(a, b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M;
	for (cin >> N >> M; M; M--) {
		int a, b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		odeg[a]++;
		ideg[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (ideg[i] == 0) in.push_back(i);
		if (odeg[i] == 0) on.push_back(i);
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		color[i] = i;
	}
	for (int i = 0; i < in.size(); i++) {
		memset(visited, 0, sizeof(visited));
		dfs(in[i]);
		for (int j = 0; j < on.size(); j++) {
			if (visited[on[j]]) {
				union_(i, j + in.size());
			}
		}
	}
	for (int i = 0; i < 40; i++) {
		if (find_(i)) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}


#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int color[40], deg[40], ideg[1000000], odeg[1000000];
bool visited[1000000];
vector<int> adj[1000000], in, on;

void dfs(int c)
{
	visited[c] = true;
	for (auto n : adj[c]) {
		if (!visited[n]) dfs(n);
	}
}

int find_(int a)
{
	if (a == color[a]) return a;
	return color[a] = find_(color[a]);
}

void union_(int a, int b)
{
	a = find_(a);
	b = find_(b);
	color[a] = color[b] = min(a, b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M;
	for (cin >> N >> M; M; M--) {
		int a, b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		odeg[a]++;
		ideg[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (ideg[i] == 0) in.push_back(i);
		if (odeg[i] == 0) on.push_back(i);
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		color[i] = i;
	}
	for (int i = 0; i < in.size(); i++) {
		memset(visited, 0, sizeof(visited));
		dfs(in[i]);
		for (int j = 0; j < on.size(); j++) {
			if (visited[on[j]]) {
				union_(i, j + in.size());
				deg[i]++;
				deg[j + in.size()]++;
			}
		}
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		if (find_(i) || deg[i] < min((int)in.size(),2)) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}


#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int color[40], deg[40], ideg[1000000], odeg[1000000];
bool visited[1000000], ovisited[20];
vector<int> adj[1000000], in, on, sadj[20];

void dfs(int c)
{
	visited[c] = true;
	for (auto n : adj[c]) {
		if (!visited[n]) dfs(n);
	}
}

int find_(int a)
{
	if (a == color[a]) return a;
	return color[a] = find_(color[a]);
}

void union_(int a, int b)
{
	a = find_(a);
	b = find_(b);
	color[a] = color[b] = min(a, b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M;
	for (cin >> N >> M; M; M--) {
		int a, b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		odeg[a]++;
		ideg[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (ideg[i] == 0) in.push_back(i);
		if (odeg[i] == 0) on.push_back(i);
	}
	for (int i = 0; i < in.size() + on.size(); i++) {
		color[i] = i;
	}
	for (int i = 0; i < in.size(); i++) {
		memset(visited, 0, sizeof(visited));
		dfs(in[i]);
		for (int j = 0; j < on.size(); j++) {
			if (visited[on[j]]) {
				sadj[i].push_back(j);
			}
		}
	}
	for (int i = 1; i < (1 << in.size()) - 1; i++) {
		int icnt = 0, ocnt = 0;
		memset(ovisited, 0, sizeof(ovisited));
		for (int j = 0; j < in.size(); j++) {
			if (i & (1 << j)) {
				icnt++;
				for (auto n : sadj[j]) {
					ovisited[n] = true;
				}
			}
		}
		for (int j = 0; j < on.size(); j++) {
			ocnt += ovisited[j];
		}
		if (icnt >= ocnt) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
	return 0;
}