#include<stdio.h>
int main()
{
    long long int h,l;
    scanf("%lld%lld",&h,&l);
    double h1=h;
    double l1=l;
    double answer=(l1*l1-h1*h1)/(2*h1);
    printf("%.8lf",answer);
    return(0);
}


#include<stdio.h>
int main()
{
    long long int h,l;
    scanf("%lld%lld",&h,&l);
    double h1=h;
    double l1=l;
    double answer=((l*l-h*h)/(2*h1));
    printf("%.13lf",answer);
    return(0);
}


#include<stdio.h>
int main(){
       float a,b,s;
       scanf("%d%d",&a,&b);
       s=(pow(b,2)-pow(a,2))/(2*b);
       printf("%.13f",s);
}


#include<stdio.h>
int main(){
       float a,b,s;
       scanf("%d%d",&a,&b);
       s=(pow(b,2)-pow(a,2))/(2*a);
       printf("%.13f",s);
}


#include<stdio.h>
#include<math.h>
int main(){
       float H,L,S;
       scanf("%f %f",&H,&L);
       S = ((float)pow(L,2)-(float)pow(H,2))/(float)(2*H);
       printf("%0.13f",S);
}


#include<stdio.h>
int main(){
       float a,b,s;
       scanf("%d%d%d",&a,&b,&s);
       s=(pow(b,2)-pow(a,2))/(2*b);
       printf("%.13f",s);
}


#include<stdio.h>
#include<math.h>
int main(){
       float a,b,s;
       scanf("%d%d",&a,&b);
       s=(pow(b,2)-pow(a,2))/(2*a);
       printf("%.13f",s);
}


#include<stdio.h>
int main(){
       float a,b,s;
       scanf("%f%f",&a,&b);
       s=(pow(b,2)-pow(a,2))/(2*a);
       printf("%.13f",s);
}


#include<stdio.h>
int main()
{
	float H, L,a;
	scanf("%f %f",&H,&L);
	a=(L*L+H*H)/(2*H);
	a=a-H;
	printf("%f",a);
}


#include<stdio.h>
int main()
{
	double H, L,a;
	scanf("%lf %lf",&H,&L);
	a=(H*H+L*L)/(2*H);
	printf("%lf",a-H);
}


#include<stdio.h>
int main()
{
	double H, L,a;
	scanf("%lf %lf",&H,&L);
	a=(L*L+H*H)/(2*H);
	a=a-H;
	printf("%lf",a);
}


    #include<stdio.h>

    int main()
    {
        int h,l;
        scanf("%d %d ",&h,&l);
        float deapth=((l*l)-(h*h))/(2*h);
        printf("%.13f",deapth);
        return 0;
    }


    #include<stdio.h>

        int main()
        {
            float h,l;
            scanf("%f %f ",&h,&l);
            float deapth=(((l*l)-(h*h))/(2*h));
            printf("%.13f",deapth);
            return 0;
        }


    #include<stdio.h>

    int main()
    {
        int h,l;
        scanf("%d %d ",&h,&l);
        float deapth=(((l*l)-(h*h))/(2*h));
        printf("%.13f",deapth);
        return 0;
    }


#include<stdio.h>

int main()
{
    int h,l;
    scanf("%d %d ",&h,&l);
    float deapth=((l*l)-(h*h))/2h;
    printf("%.13f",deapth);
    return 0;
}


#include<stdio.h>

    int main()
    {
        float h,l;
        scanf("%d %d ",&h,&l);
        float deapth=(((l*l)-(h*h))/(2*h));
        printf("%.13f",deapth);
        return 0;
    }


#include<stdio.h>
int main(){
    double h,l,t,j,k;
    scanf("%lf",&h);
    scanf("%lf",&l);
    t=(2*h);
    j=(l*l)-(h*h);
    k=j/t;
    printf("%lf",k);
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    double h,l;
    cin>>h>>l;
    double s = (l*l-h*h)/2/h;;
    printf("%.12lf",s);
}


#include<stdio.h>
int main(){
   float h,l,t,j,k;
    scanf("%f",&h);
    scanf("%f",&l);
    t=(2*h);
    j=(l*l)-(h*h);
    k=j/t;
    printf("%f",k);
}


#include<stdio.h>
int main(){
    double h,l;
    scanf("%lf",&h);
    scanf("%lf",&l);
    double s = (l*l-h*h)/2/h;;
    printf("%lf",s);
}


#include <stdio.h>
#include<math.h>

int
main()
{
	float H,L;
	float res;
	scanf("%f%f",&H,&L);
	res = (L*L - H*H )/ (2*H);
	printf("%f",res);
	return 0;
}


/*
* water lily problem
*/
#include <stdio.h>
#include<math.h>

int
main()
{
	double H,L;
	double res;
	scanf("%lf%lf",&H,&L);
	res = (pow(L,2) - pow (H,2) ) / 2*H;
	printf("%lf",res);
	return 0;
}


#include <stdio.h>
#include<math.h>

int
main()
{
	float H,L;
	float res;
	scanf("%f%f",&H,&L);
	res = (pow(L,2) - pow (H,2) ) / 2*H;
	printf("%f",res);
	return 0;
}


#include <stdio.h>

int main()
{
    long long int h, l;
    double x;
    scanf("%lld %lld", &h, &l);
    x=(double)((l*l)-(h*h))/(2*h);
    printf("%f", x);
}


#include <stdio.h>

int main()
{
    int h, l;
    float x;
    scanf("%d %d", &h, &l);
    x = (float)((l*l)-(h*h))/(2*h);
    printf("%f", x);
}


#include <stdio.h>

struct n{
    double x;
}*head;

int main()
{
    head = (struct n *)malloc(sizeof(struct n));
    long long int h, l;
    scanf("%lld %lld", &h, &l);
    head->x=(double)((l*l)-(h*h))/(2*h);
    printf("%f", head->x);
}


#include<stdio.h>
#include<math.h>
int main()
{
	float h,l;
scanf("%f %f",&h,&l);
printf("%.13f",(pow(l,2)-pow(h,2))/(2*h));
return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
	double h,l;
				double x,a,y,z,p,q;
				scanf("%lf %lf",&h,&l);
				x=(l/h);
				y=atan(x);
				p=(y*180)/3.1416;

			z=(2*p)-90;

			q=(z*3.1416)/180;
			a=l*tan(q);
				printf("%lf",a);
				return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
	int h,l;
				double x,a,y,z,p;
				scanf("%d %d",&h,&l);
				x=(l/h);
				y=atan(x);
				p=(y*180)/3.1416;

			z=(2*p)-90;

			p=(z*3.1416)/180;
			a=l*tan(p);
				printf("%lf",a);
				return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
	int h,l;
				double x,a,y,z,p,q;
				scanf("%d %d",&h,&l);
				x=(l/h);
				y=atan(x);
				p=(y*180)/3.1416;

			z=(2*p)-90;

			q=(z*3.1416)/180;
			a=l*tan(q);
				printf("%lf",a);
				return 0;
}


#include<stdio.h>
#include<math.h>
#define pi 3.14159265358979323846

int main()
{
	double h,l;
				double x,a,y,z,p,q;
				scanf("%lf %lf",&h,&l);
				x=(l/h);
				y=atan(x);
				p=(y*180)/pi;

			z=(2*p)-90;

			q=(z*pi)/180;
			a=l*tan(q);
				printf("%.13lf",a);
				return 0;
	}


#include<stdio.h>
#include<math.h>
#define pi 3.14159265358979323846

int main()
{
	double h,l;
				double x,a,y,z,p,q;
				scanf("%lf %lf",&h,&l);
				x=(l/h);
				y=atan(x);
				p=(y*180)/pi;

			z=(2*p)-90;

			q=(z*pi)/180;
			a=l*tan(q);
				printf("%lf",a);
				return 0;
	}


#include <stdio.h>

double   x, l, h;
int main()
{

    scanf("%lf  %lf", &h, &l);

    printf("%lf", (l*l - h*h) / ( 2*h));

    return 0;
}


#include <stdio.h>

float   x, l, h;
int main()
{

    scanf("%f  %f", &h, &l);

    printf("%f", (l*l - h*h) / ( 2*h));

    return 0;
}


#include<stdio.h>
int main(void)
{
    double h,l,ans;
    scanf("%lf %lf",&h,&l);
    ans=(l*l-h*h)/(2*h);
    printf("%.13lf",ans);
    return 0;
}


    #include<stdio.h>
    int main(void)
    {
        double h,l,ans;
        scanf("%lf %lf",&h,&l);
        ans=(l*l-h*h)/(2*h);
        printf("%.13f",ans);
        return 0;
    }


#include <stdio.h>
main();

    int main() {
    int h, l;
    scanf("%d%d", &h, &l);
    printf("%.13lf\n", (l*l-h*h)/(2.0*h));
}


#include <stdio.h>
main();

    int main() {
    int h, l;
    scanf("%d%d", &h, &l);
    printf("%.13f\n", (l*l-h*h)/(2.0*h));
}


#include<bits/stdc++.h>

using namespace std;

#define NN 200000

vector<int>adj[NN];

int vis[NN],f[NN],cnt;

int dfs(int u,int fa=-1)

{

	vis[u]=1;

	int tot=1; cnt+=adj[u].size();

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(vis[v] || v==fa)continue;

		tot+=dfs(v,u);

	}

	return tot;

}

int main()

{

	int n,m,u,v;

//	freopen("in.txt","r",stdin);

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

	while(m--){

		scanf("%d%d",&u,&v);

		adj[u].push_back(v); adj[v].push_back(u);

	}

	for(int i=1;i<=n;i++){

		if(!vis[i]){

			cnt=0;

		    int tot=dfs(i);

		    if(tot*(tot-1)!=cnt){puts("NO");return 0;}

		}

	}

	puts("YES");

	return 0;

}


#include <bits/stdc++.h>

#define NN 200000

using namespace std;

int cnt[NN];

int main(){

	int N, M, i, k, u, v;

	while(scanf("%d%d", &N, &M)==2){

		memset(cnt, 0, sizeof(cnt));

		for(i=0; i<M; i++){

			scanf("%d%d", &u, &v);

			cnt[u]++;

			cnt[v]++;

		}

		sort(cnt, cnt+N);

		k=0;

		cnt[0]=cnt[N+1]=-1;

		for(i=1; i<=N; i++){

			if(!cnt[i]) continue;

			if(cnt[i]!=cnt[i-1]&&cnt[i]!=cnt[i+1]) k=1;

		}

		if(k) puts("NO");

		else puts("YES");

	}

}


#include <bits/stdc++.h>

#define NN 200000

using namespace std;

int cnt[NN], a[NN];

int main(){

	int N, M, i, k, u, v;

	while(scanf("%d%d", &N, &M)==2){

		memset(a, 0, sizeof(a));

		memset(cnt, 0, sizeof(cnt));

		for(i=0; i<M; i++){

			scanf("%d%d", &u, &v);

			cnt[u]++;

			cnt[v]++;

		}

		for(i=1; i<=N; i++){

			a[cnt[i]]++;

		}

		for(i=0; i<N; i++)

			if(a[i]%(i+1)) break;

		if(i<N) puts("NO");

		else puts("YES");

	}

}


#include<bits/stdc++.h>

using namespace std;

#define NN 1111111

vector <int> adj[NN];

int deg[NN], vet[NN];

int main (){

	int m, n, i, flag = 0, u, v;

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

	memset (deg, 0, sizeof(deg));

	memset (vet, 0, sizeof(vet));

	for( i=0; i<m; i++ ) adj[i].clear();

	for( i=0; i<m; i++ ){

		scanf("%d%d", &u, &v);

		adj[u].push_back(v);

		adj[v].push_back(u);

		deg[u]++;

		deg[v]++;

	}

	queue <int> q = queue<int>();

	for( i=0; i<n; i++ ){

		if( !deg[i] ) continue;

		if( vet[i] )  continue;

		q.push(i);

		vet[i] = 1;

		while( !q.empty() ){

			u=q.front(); q.pop();

			if( deg[i] != deg[u] ) flag = 1;

			for( int k=0; k<deg[u]; k++ ){

				v = adj[u][k];

				if( vet[v] ) continue;

				vet[v] = 1;

				q.push(v);

			}

		}

	}

	puts(flag? "NO" : "YES" );

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 150010;

vector<int> adj[maxn];

int vst[maxn], ok, cnt;

void dfs( int u ) {

	cnt++;

	vst[u] = 1;

	for( int i = 0; i < adj[u].size(); i ++ ) {

	 	int v = adj[u][i];

	 	if ( vst[v] ) continue;

		dfs( v );

	}

}

void rdfs( int u ) {

	vst[u] = 2;

	if ( adj[u].size() != cnt - 1 ) { ok = 0; return ; }

	for( int i = 0; i < adj[u].size(); i ++ ) {

	 	int v = adj[u][i];

	 	if ( ok == 0 ) return;

	 	if ( vst[u] == 2 ) continue;

		rdfs( v );

	}

}

int main() {

	int n, m, u, v;

	cin >> n >> m;

	for( int i = 0; i < m; i ++ ) {

		scanf("%d%d", &u, &v);

		adj[u].push_back(v);

		adj[v].push_back(u);

	}

	ok = 1;

	for ( int i = 1; i <= n && ok; i ++  ){

		if ( vst[i] ) continue;

		cnt = 0;

		dfs( i );

		rdfs( i );

	}

	if ( ok ) puts("YES");

	else puts("NO");

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define bpt(x) (__builtin_popcount(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bit(x, y) (((x)>>(y))&1)

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<class T, class U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<class T, class U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c,sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if (c==-1) return ;if (c=='-') sg=1,c=getchar(); for (x=0; c>='0' && c<='9'; x=(x<<1)+(x<<3)+c-'0', c=getchar());if (sg) x=-x;}

template<class T> void print(T x) {if (x<0) return putchar('-'), print(-x);if (x<10) {putchar(x+'0');return ;} print(x/10);putchar(x%10+'0');}

template<class U, class V>inline void gn(U &u, V &v){gn(u);gn(v);}

template<class U, class V, class W>inline void gn(U &u, V &v, W &w){gn(u); gn(v, w);}

template<class T> void println(T &x) {print(x);putchar('\n');}

template<class T> void printsp(T &x) {print(x);putchar(' ');}

template<class U, class V> inline void print(U &u, V &v) {printsp(u);println(v);}

template<class U, class V, class W> inline void print(U &u, V &v, W &w){printsp(u);print(v, w);}

int power(int a, int b, int m, int ans=1) {

	for (; b; a=(INT)a*a%m,b>>=1) if (b&1) ans=(INT)ans*a%m;

	return ans;

}

#define NN 220202

INT cnt,tot;

VI adj[NN];

int vst[NN];

void judge(int u){

	vst[u]=1;

	cnt++;

	tot+=adj[u].size();

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(vst[v]) continue;

		judge(v);

	}

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n,m;

	gn(n,m);

	for(int i=0;i<m;i++){

		int a,b;

		gn(a,b);

		adj[a].push_back(b);

		adj[b].push_back(a);

	}

	int flag=0;

	for(int i=1;i<=n;i++){

		if(vst[i]) continue;

		cnt=0,tot=0;

		judge(i);

		if(cnt*(cnt-1)!=tot){

			flag=1;

			break;

		}

	}

	if(flag) {

		puts("NO");

		return 0;

	}

	else puts("YES");

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 200000

vector<int>adj[NN];

int vis[NN];

long long cnt=0;

int dfs(int u,int fa=-1)

{

	vis[u]=1;

	int tot=1; cnt+=adj[u].size();

	for(int i=0;i<adj[u].size();i++){

		int v=adj[u][i];

		if(vis[v] || v==fa)continue;

		tot+=dfs(v,u);

	}

	return tot;

}

int main()

{

	int n,m,u,v;

//	freopen("in.txt","r",stdin);

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

	while(m--){

		scanf("%d%d",&u,&v);

		adj[u].push_back(v); adj[v].push_back(u);

	}

	for(int i=1;i<=n;i++){

		if(!vis[i]){

			cnt=0;

		    int tot=dfs(i);

		    if(1LL*tot*(tot-1)!=cnt){puts("NO");return 0;}

		}

	}

	puts("YES");

	return 0;

}


#include <bits/stdc++.h>

#define NN 150010

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

vector<int> adj[NN];

vector<int> L[NN];

bool vst[NN];

int deg[NN];

int dfs(int u, int k){

	L[k].push_back(u);

	vst[u]=1;

	for(int i=adj[u].size(); i--;){

		int v=adj[u][i];

		if(vst[v]) continue;

		dfs(v, k);

	}

	return 0;

}

int main(){

	int N, M, u, v;

	cin>>N>>M;

	for(int i=0; i<M; i++){

		scanf("%d%d", &u, &v);

		u--, v--;

		adj[u].push_back(v);

		adj[v].push_back(u);

		deg[u]++, deg[v]++;

	}

	int K=0;

	for(int i=0; i<N; i++){

		if(vst[i]) continue;

		dfs(i, K);

		K++;

	}

	bool ok=1;

	for(int i=0; i<K; i++){

		int flag=0;

		int LL=(int)L[i].size()-1;

		for(int j=0; j<=LL; j++){

			u=L[i][j];

			if(deg[u]!=LL) flag=1;

		}

		if(flag) {ok=0; break;}

	}

	if(ok) puts("YES");

	else puts("NO");

}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 150010;

vector<int> adj[maxn];

int vst[maxn], ok;

int dfs( int u ) {

	int cnt = 1;

	vst[u] = 1;

	for( int i = 0; i < adj[u].size() && ok; i ++ ) {

	 	int v = adj[u][i];

	 	if ( vst[v] ) continue;

	 	if ( adj[u].size() != adj[v].size() ) { ok = 0; return 0;  }

		cnt += dfs( v );

	}

	return cnt;

}

int main() {

	int n, m, u, v;

	cin >> n >> m;

	for( int i = 0; i < m; i ++ ) {

		scanf("%d%d", &u, &v);

		adj[u].push_back(v);

		adj[v].push_back(u);

	}

	ok = 1;

	for ( int i = 1; i <= n && ok; i ++  ){

		if ( vst[i] ) continue;

		if ( adj[i].size() == 0 ) continue;

		int cnt = dfs( i );

		if ( cnt != adj[i].size() + 1 ) ok = 0;

	}

	if ( ok ) puts("YES");

	else puts("NO");

	return 0;

}


#include <bits/stdc++.h>

#define NN 200000

using namespace std;

vector<int> adj[NN];

int vst[NN], deg[NN];

int main(){

	int N, M, i, k, u, v;

	while(scanf("%d%d", &N, &M)==2){

		memset(vst, 0, sizeof(vst));

		memset(deg, 0, sizeof(deg));

		for(i=1; i<=N; i++) adj[i].clear();

		for(i=0; i<M; i++){

			scanf("%d%d", &u, &v);

			deg[u]++;

			deg[v]++;

			adj[u].push_back(v);

			adj[v].push_back(u);

		}

		int flag=0, n;

		queue<int> q=queue<int>();

		for(i=1; i<=N; i++){

			if(deg[i]==0) continue;

			if(vst[i]) continue;

			vst[i]=1;

			n=0;

			q.push(i);

			while(!q.empty()){

				u=q.front();q.pop();

				n++;

				for(k=0; k<deg[u]; k++){

					v=adj[u][k];

					if(vst[v]) continue;

					vst[v]=1;

					q.push(v);

				}

			}

			deg[i]=n-1;

		}

		memset(vst, 0, sizeof(vst));

		for(i=1; i<=N; i++){

			if(deg[i]==0) continue;

			if(vst[i]) continue;

			q.push(i);

			vst[i]=1;

			while(!q.empty()){

				u=q.front();q.pop();

				if(deg[u]!=deg[i]) flag=1;

				if(flag) continue;

				for(k=0; k<adj[u].size(); k++){

					v=adj[u][k];

					if(vst[v]) continue;

					vst[v]=1;

					q.push(v);

				}

			}

		}

		if(flag) puts("NO");

		else puts("YES");

	}

}


#include<bits/stdc++.h>

using namespace std;

#define NN 1111111

vector <int> adj[NN];

int deg[NN], vet[NN];

int main (){

	int m, n, i, flag = 0, u, v;

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

	memset (deg, 0, sizeof(deg));

	memset (vet, 0, sizeof(vet));

	for( i=0; i<m; i++ ) adj[i].clear();

	for( i=0; i<m; i++ ){

		scanf("%d%d", &u, &v);

		adj[u].push_back(v);

		adj[v].push_back(u);

		deg[u]++;

		deg[v]++;

	}

	queue <int> q = queue<int>();

	for(i=0; i<n; i++){

		if(!deg[i]) continue;

		if(vet[i]) continue;

		q.push(i);

		vet[i] = 1;

		n = 0;

		while (!q.empty()){

			u = q.front();  q.pop();

			n++;

			for(int k = 0; k<deg[i]; k++){

				v = adj[u][k];

				if(vet[v]) continue;

				vet[v] = 1;

				q.push(u);

			}

		}

		deg[i] = n-1;

	}

	memset(vet, 0, sizeof(vet));

	q = queue<int>();

	for( i=0; i<n; i++ ){

		if( !deg[i] ) continue;

		if( vet[i] )  continue;

		q.push(i);

		vet[i] = 1;

		while( !q.empty() ){

			u=q.front(); q.pop();

			if( deg[i] != deg[u] ) flag = 1;

			for( int k=0; k<deg[u]; k++ ){

				v = adj[u][k];

				if( vet[v] ) continue;

				vet[v] = 1;

				q.push(v);

			}

		}

	}

	puts(flag? "NO" : "YES" );

	return 0;

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 155555

int vst[NN],dig[NN];

vector <int> mp[NN];

queue <int> q;

int main(){

	int i,j;

	int st;

	int s;

	int v,u;

	int n,m;

	int a,b;

	while(scanf("%d%d",&n,&m)==2){

		for(i=0;i<m;i++)

			mp[i].clear();

		for(i=0;i<m;i++){

			scanf("%d%d",&a,&b);

			a--;b--;

			mp[a].push_back(b);

			mp[b].push_back(a);

		}

		memset(vst,0,sizeof(vst));

		memset(dig,0,sizeof(dig));

		for(i=0;i<n;i++){

			if(vst[i]==1)continue;

			vst[i]=1;

			q=queue <int> ();

			q.push(i);st=1;

			while(!q.empty()){

				u=q.front();q.pop();

				for(j=0;j<mp[u].size();j++){

					v=mp[u][j];

					if(vst[v]==1)continue;

					vst[v]=1;

					st++;

					q.push(v);

				}

			}

			dig[i]=st;

		}

		s=0;

		for(i=0;i<n;i++){

			if(dig[i]==1)continue;

			s+=dig[i]*(dig[i]-1)/2;

		}

		if(s==m)

			puts("YES");

		else

			puts("NO");

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 150111

#define PB push_back

int vst[NN], deg[NN],flag;

long long edges;

vector <int> vec[NN];

void dfs(int v){

	vst[v]=1;

	for(int i=0;i<deg[v];i++){

		int u=vec[v][i];

		if(vst[u]) continue;

		if(deg[u]!=deg[v]) flag=1;

		edges+=deg[u];

		dfs(u);

	}

}

int main(){

	int n,m,i,a,b;

	cin>>n>>m;

	for(i=0;i<m;i++){

		cin>>a>>b;

		vec[a].PB(b);

		vec[b].PB(a);

		deg[a]++;

		deg[b]++;

	}

	for(i=1;i<=n;i++){

		if(vst[i]) continue;

		edges=deg[i];

		flag=0;

		dfs(i);

		if(flag||edges!=1LL*deg[i]*(deg[i]+1)) {puts("NO");return 0;}

	}

	puts("YES");

	return 0;

}


#include <bits/stdc++.h>

#define NN 200000

using namespace std;

vector<int> adj[NN];

int vst[NN], deg[NN];

int main(){

	int N, M, i, k, u, v;

	while(scanf("%d%d", &N, &M)==2){

		memset(vst, 0, sizeof(vst));

		memset(deg, 0, sizeof(deg));

		for(i=1; i<=N; i++) adj[i].clear();

		for(i=0; i<M; i++){

			scanf("%d%d", &u, &v);

			deg[u]++;

			deg[v]++;

			adj[u].push_back(v);

			adj[v].push_back(u);

		}

		int flag=0;

		queue<int> q=queue<int>();

		for(i=1; i<=N; i++){

			if(deg[i]==0) continue;

			if(vst[i]) continue;

			q.push(i);

			vst[i]=1;

			while(!q.empty()){

				u=q.front();q.pop();

				if(deg[u]!=deg[i]) flag=1;

				if(flag) continue;

				for(k=0; k<deg[u]; k++){

					v=adj[u][k];

					if(vst[v]) continue;

					vst[v]=1;

					q.push(v);

				}

			}

		}

		if(flag) puts("NO");

		else puts("YES");

	}

}


#include <bits/stdc++.h>

#define NN 200000

using namespace std;

int cnt[NN];

int main(){

	int N, M, i, k, u, v;

	while(scanf("%d%d", &N, &M)==2){

		memset(cnt, 0, sizeof(cnt));

		for(i=0; i<M; i++){

			scanf("%d%d", &u, &v);

			cnt[u]++;

			cnt[v]++;

		}

		k=0;

		for(i=1; i<=N; i++){

			if(!cnt[i]) continue;

			if(!k) k=cnt[i];

			else if(k!=cnt[i]) break;

		}

		if(i<=N) puts("NO");

		else puts("YES");

	}

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 155555

int cnt[NN];

int main(){

	int i,j;

	int n,m;

	int a,b;

	while(scanf("%d%d",&n,&m)==2){

		memset(cnt,0,sizeof(cnt));

		for(i=0;i<m;i++){

			scanf("%d%d",&a,&b);

			cnt[a]++;

			cnt[b]++;

		}

		for(i=1;i<=n;i++)

			if(cnt[i]%2)

				break;

		if(i==n+1)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}


#include <bits/stdc++.h>

#define NN 200010

#define inf 0x3f3f3f3f

#define mod 1000000007

using namespace std;

typedef long long INT;

vector<int> adj[NN];

int vst[NN], deg[NN];

int main(){

	int N, M, u, v;

	cin>>N>>M;

	for(int i=0; i<M; i++){

		scanf("%d%d", &u, &v);

		u--, v--;

		adj[u].push_back(v);

		adj[v].push_back(u);

		deg[u]++, deg[v]++;

	}

	bool ok=1;

	for(int i=0; i<N; i++){

		if(vst[i]) continue;

		queue<int> q=queue<int>();

		q.push(i);

		vst[i]=1;

		int n=0;

		while(!q.empty()){

			u=q.front(); q.pop();

			n++;

			for(int j=0; j<adj[u].size(); j++){

				v=adj[u][j];

				if(vst[v]) continue;

				vst[v]=1;

				q.push(v);

			}

		}

		q.push(i);

		int flag=0;

		while(!q.empty()){

			u=q.front();q.pop();

			vst[u]=2;

			if(deg[u]!=n-1) flag=1;

			for(int j=0; j<adj[u].size(); j++){

				v=adj[u][j];

				if(vst[v]==2) continue;

				q.push(v);

			}

		}

		if(flag) {ok=0; break;}

	}

	if(ok) puts("YES");

	else puts("NO");

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 155555

int cnt[NN];

int main(){

	int i,j;

	int n,m;

	int a,b;

	while(scanf("%d%d",&n,&m)==2){

		memset(cnt,0,sizeof(cnt));

		for(i=0;i<m;i++){

			scanf("%d%d",&a,&b);

			cnt[a]++;

			cnt[b]++;

		}

		if(m<3){printf("NO\n");continue;}

		for(i=1;i<=n;i++)

			if(cnt[i]%2&&cnt[i]>1)

				break;

		if(i==n+1)

			printf("YES\n");

		else

			printf("NO\n");

	}

	return 0;

}


#define ONLINE_JUDGE
#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define mod 1000000007

#define pb push_back

#define x first

#define y second

#define eps 1e-7

#define sq(x) ((x)*(x))

#define cb(x) ((x)*(x)*(x))

#define pi 3.1415926535897932384626433832795

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template <class T> inline void gn(T &x) {char c, sg=0;while (c=getchar(), (c>'9' || c<'0') && c!='-' && c!=-1);if(c==-1) return;x=0;(c=='-'?sg=1, c=getchar():0);for(; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template <class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;}print(x/10);putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x);putchar('\n');}

template <class T> inline void printsp(T x) {print(x);putchar(' ');}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

#define DEBUG

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 150010

VI adj[NN];

int vst[NN];

INT cnt, deg;

void dfs(int u) {

	vst[u]=1;

	int n=adj[u].size();

	deg++, cnt+=n;

	for(int i=0; i<n; i++) {

		int v=adj[u][i];

		if(vst[v]) continue;

		dfs(v);

	}

}

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n, m;

	gn(n), gn(m);

	while(m--) {

		int u, v;

		gn(u), gn(v);

		adj[u].pb(v), adj[v].pb(u);

	}

	for(int i=1; i<=n; i++) {

		if(vst[i]) continue;

		deg=cnt=0;

		dfs(i);

		if(deg*(deg-1)!=cnt) return puts("NO"), 0;

	}

	puts("YES");

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

#define NN 1111111

vector <int> adj[NN];

int deg[NN], vet[NN];

int main (){

	int m, n, i, flag = 0, u, v;

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

	memset (deg, 0, sizeof(deg));

	memset (vet, 0, sizeof(vet));

	for( i=0; i<m; i++ ) adj[i].clear();

	for( i=0; i<m; i++ ){

		scanf("%d%d", &u, &v);

		adj[u].push_back(v);

		adj[v].push_back(u);

		deg[u]++;

		deg[v]++;

	}

	queue <int> q = queue<int>();

	for(i=1; i<=n; i++){

		if( !deg[i] ) continue;

		if( vet[i] ) continue;

		q.push(i);

		vet[i] = 1;

		n = 0;

		while (!q.empty()){

			u = q.front();  q.pop();

			n++;

			for(int k = 0; k<deg[i]; k++){

				v = adj[u][k];

				if(vet[v]) continue;

				vet[v] = 1;

				q.push(u);

			}

		}

		deg[i] = n-1;

	}

	memset(vet, 0, sizeof(vet));

	q = queue<int>();

	for( i=1; i<=n; i++ ){

		if( !deg[i] ) continue;

		if( vet[i] )  continue;

		q.push(i);

		vet[i] = 1;

		while( !q.empty() ){

			u=q.front(); q.pop();

			if( deg[i] != deg[u] ) flag = 1;

			for( int k=0; k<deg[u]; k++ ){

				v = adj[u][k];

				if( vet[v] ) continue;

				vet[v] = 1;

				q.push(v);

			}

		}

	}

	puts(flag? "NO" : "YES" );

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

int ans[100];

string a;

char str[100][2];

int main()

{

	int n,k,tot=0,cnt=1;

//	freopen("in.txt","r",stdin);

	for(int i=1;i<=26;i++)str[i][0]='A'+i-1, str[i][1]='a'+i-1, str[i][2]=0;

	for(int i=27;i<=50;i++)str[i][0]='A'+i-1, str[i][1]='b'+i-1, str[i][2]=0;

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

	for(int i=1;i<k;i++)ans[i]=i;

	for(int i=k;i<=n;i++){

		cin>>a;

		if(a=="NO")ans[i]=ans[i-k+1];

		else ans[i]=i;

	}

	for(int i=1;i<=n;i++)cout<<str[ans[i]][0]<<str[ans[i]][1]<<" "; cout<<endl;

}


#include<bits\stdc++.h>

using namespace std;

typedef long long INT;

typedef pair<int,int> pii;

#define NN 155555

int vst[NN],dig[NN];

vector <int> mp[NN];

queue <int> q;

int main(){

	int i,j;

	int st;

	int s;

	int v,u;

	int n,m;

	int a,b;

	while(scanf("%d%d",&n,&m)==2){

		for(i=0;i<m;i++)

			mp[i].clear();

		for(i=0;i<m;i++){

			scanf("%d%d",&a,&b);

			a--;b--;

			mp[a].push_back(b);

			mp[b].push_back(a);

		}

		memset(vst,0,sizeof(vst));

		memset(dig,0,sizeof(dig));

		for(i=0;i<n;i++){

			if(vst[i]==1)continue;

			vst[i]=1;

			q=queue <int> ();

			q.push(i);st=1;

			while(!q.empty()){

				u=q.front();q.pop();

				for(j=0;j<mp[u].size();j++){

					v=mp[u][j];

					if(vst[v]==1)continue;

					vst[v]=1;

					st++;

					q.push(v);

				}

			}

			dig[i]=st;

		}

		for(i=0;i<n;i++)

			printf("%d ",dig[i]);

		puts("");

		s=0;

		for(i=0;i<n;i++){

			if(dig[i]==1)continue;

			s+=dig[i]*(dig[i]-1)/2;

		}

		if(s==m)

			puts("YES");

		else

			puts("NO");

	}

	return 0;

}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 150010;

vector<int> adj[maxn];

int vst[maxn], ok, cnt;

void dfs( int u ) {

	cnt++;

	vst[u] = 1;

	for( int i = 0; i < (int)adj[u].size(); i ++ ) {

	 	int v = adj[u][i];

	 	if ( vst[v] ) continue;

		dfs( v );

	}

}

void rdfs( int u, int cnt ) {

	vst[u] = 2;

	if ( adj[u].size() != cnt - 1 ) { ok = 0; return ; }

	for( int i = 0; i < adj[u].size(); i ++ ) {

	 	int v = adj[u][i];

	 	if ( ok == 0 ) return;

	 	if (vst[u] == 2 ) continue;

		rdfs( v, cnt );

	}

}

int main() {

	int n, m, u, v;

	cin >> n >> m;

	for( int i = 0; i < m; i ++ ) {

		scanf("%d%d", &u, &v);

		adj[u].push_back(v);

		adj[v].push_back(u);

	}

	ok = 1;

	for ( int i = 1; i <= n && ok; i ++  ){

		if ( vst[i] ) continue;

		cnt = 0;

		dfs( i );

		rdfs( i, cnt );

	}

	if ( ok ) puts("YES");

	else puts("NO");

	return 0;

}


#include <iostream>
using namespace std;

long long fi(long long);

long long u[200000];
long long p[200000];

int main()
{
    for(int i=1; i!=150001; ++i)
    {
        u[i] = i;
        p[i] = 1;
    }
    long long n, m, a, b, c, d, sum = 0;
    cin >> n >> m;
    for(int i=1; i!=m+1; ++i)
    {
        cin >> a >> b;
        c = fi(a);
        d = fi(b);
        if(c!=d)
        {
            u[d] = c;
            p[c]+=p[d];
        }
    }
    for(int i=1; i!=n+1; ++i)
    {
        if(p[i]>1&&u[i]==i)
        {
            sum+=p[i]*(p[i]-1)/2;
        }
    }
    if(sum>m)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}

long long fi(long long x)
{
    if(u[x]!=x)
        return fi(u[x]);
    else
        return x;
}


#include <iostream>
using namespace std;

long long fi(long long);

long long u[200000];
long long p[200000];

int main()
{
    for(int i=1; i!=150001; ++i)
    {
        u[i] = i;
        p[i] = 1;
    }
    long long n, m, a, b, c, d, sum = 0;
    cin >> n >> m;
    for(int i=1; i!=m+1; ++i)
    {
        cin >> a >> b;
        c = fi(a);
        d = fi(b);
        if(c!=d)
        {
            u[d] = c;
            p[c]+=p[d];
        }
    }
    for(int i=1; i!=n+1; ++i)
    {
        if(p[i]>1&&u[i]==i)
        {
            sum+=p[i]*(p[i]-1)/2;
        }
    }
    if(sum>m)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}

long long fi(long long x)
{
    if(u[x]!=x)
    {
        u[x] = fi(u[x]);
        return u[x];
    }
    else
        return x;
}


#include <iostream>
using namespace std;

long long fi(long long);

long long u[200000];
long long p[200000];

int main()
{
    for(int i=1; i!=150001; ++i)
    {
        u[i] = i;
        p[i] = 1;
    }
    long long n, m, a, b, c, d, sum = 0;
    cin >> n >> m;
    for(int i=1; i!=m+1; ++i)
    {
        cin >> a >> b;
        c = fi(a);
        d = fi(b);
        if(c!=d)
        {
            u[d] = c;
            p[c]+=p[d];
        }
    }
    for(int i=1; i!=n+1; ++i)
    {
        if(p[i]>1)
        {
            sum+=p[i]*(p[i]-1)/2;
        }
    }
    if(sum>m)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}

long long fi(long long x)
{
    if(u[x]!=x)
        return fi(u[x]);
    else
        return x;
}


#include <iostream>
using namespace std;

long long fi(long long);

long long u[200000];
long long p[200000];

int main()
{
    for(int i=1; i!=150001; ++i)
    {
        u[i] = i;
        p[i] = 1;
    }
    long long n, m, a, b, c, d, sum = 0;
    cin >> n >> m;
    for(int i=1; i!=m+1; ++i)
    {
        cin >> a >> b;
        c = fi(a);
        d = fi(b);
        if(c!=d)
        {
            u[d] = c;
            p[c]+=p[d];
        }
    }
    for(int i=1; i!=n+1; ++i)
    {
        if(p[i]>1&&u[i]==i)
        {
            sum+=p[i]*(p[i]-1)/2;
        }
    }
    if(sum>m)
        cout << "NO";
    else
        cout << "YES";
    return 0;
}

long long fi(long long x)
{
    return (u[x]==x)?x:(u[x]=fi(u[x]));
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000],vv[200000],sum[200000],nn;
typedef struct hu
{
    int a,b;
};
hu kk[200000];
vector<int>edg[200000];
int dfs(int node,int deep)
{
    int flag=0,t=edg[node].size(),re=0;
    for(int i=t-1;i>=0;i--)
    {
        int nodenow=edg[node][i];
        if(!vv[nodenow])
        {
            vv[nodenow]=1;
            sum[nodenow]=dfs(nodenow,deep+1);
            re=sum[nodenow];
            flag=1;
        }
        if(nodenow==nn)
        t=1;
    }
    if(!flag)
    {
        if(t==1)
        return deep+1;
        else
        return deep;
    }
    return re;
}
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
        edg[a1].push_back(b1);
        edg[b1].push_back(a1);
    }
    ff(i,1,n)
    {
        int p=kk[i].a;
        if(!vv[p])
        {
            nn=p;
            vv[p]=1;
            sum[p]=dfs(p,0);
        }
    }
    ff(i,1,n)
    {

        if(vis[kk[i].a]!=vis[kk[i].b]||vis[kk[i].a]!=sum[kk[i].a]-1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000];
typedef struct hu
{
    int a,b;
};
hu kk[200000];
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
    }
    ff(i,1,n)
    {
        if(vis[kk[i].a]!=vis[kk[i].b])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000],vv[200000],sum[200000],nn;
typedef struct hu
{
    int a,b;
};
hu kk[200000];
vector<int>edg[200000];
int dfs(int node,int deep)
{
    int flag=0,t=0,re=0;
    for(int i=0;i<edg[node].size();i++)
    {
        int nodenow=edg[node][i];
        if(!vv[nodenow])
        {
            vv[nodenow]=1;
            int kt=dfs(nodenow,deep+1);
            if(sum[nodenow]<kt)
            sum[nodenow]=kt;
            vv[nodenow]=0;
            re=sum[nodenow];
            flag=1;
        }
        if(nodenow==nn)
        t=1;
    }
    if(!flag)
    {
        if(t==1)
        return deep+1;
        else
        return deep;
    }
    return re;
}
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
        edg[a1].push_back(b1);
        edg[b1].push_back(a1);
    }
    ff(i,1,n)
    {
        int p=kk[i].a;
        if(!vv[p])
        {
            nn=p;
            vv[p]=1;
            sum[p]=dfs(p,0);
        }
    }
   // ff(i,1,n)
   // {
      //  cout<<sum[kk[i].a]<<"   "<<sum[kk[i].b]<<endl;
    //}
    ff(i,1,n)
    {

        if(vis[kk[i].a]!=vis[kk[i].b]||vis[kk[i].a]!=sum[kk[i].a]-1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000],vv[200000],sum[200000],nn;
typedef struct hu
{
    int a,b;
};
hu kk[200000];
vector<int>edg[200000];
int dfs(int node,int deep)
{
    int flag=0,t=0,re=0;
    for(int i=0;i<edg[node].size();i++)
    {
        int nodenow=edg[node][i];
        if(!vv[nodenow])
        {
            vv[nodenow]=1;
            int kt=dfs(nodenow,deep+1);
            if(sum[nodenow]<kt)
            sum[nodenow]=kt;
            vv[nodenow]=0;
            re=sum[nodenow];
            flag=1;
        }
        if(nodenow==nn)
        t=1;
    }
    if(!flag)
    {
        if(t==1)
        return deep+1;
        else
        return deep;
    }
    return re;
}
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
        edg[a1].push_back(b1);
        edg[b1].push_back(a1);
    }
    ff(i,1,n)
    {
        int p=kk[i].a;
        if(!vv[p])
        {
            nn=p;
            vv[p]=1;
            sum[p]=dfs(p,0);
        }
    }
    ff(i,1,n)
    {
        cout<<sum[kk[i].a]<<"   "<<sum[kk[i].b]<<endl;
    }
    ff(i,1,n)
    {

        if(vis[kk[i].a]!=vis[kk[i].b]||vis[kk[i].a]!=sum[kk[i].a]-1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000],vv[200000],sum[200000],nn;
typedef struct hu
{
    int a,b;
};
hu kk[200000];
vector<int>edg[200000];
int dfs(int node,int deep)
{
    int flag=0,t=0,re=0;
    for(int i=0;i<edg[node].size();i++)
    {
        int nodenow=edg[node][i];
        if(!vv[nodenow])
        {
            vv[nodenow]=1;
            sum[nodenow]=dfs(nodenow,deep+1);
            re=sum[nodenow];
            flag=1;
        }
        if(nodenow==nn)
        t=1;
    }
    if(!flag)
    {
        if(t==1)
        return deep+1;
        else
        return deep;
    }
    return re;
}
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
        edg[a1].push_back(b1);
        edg[b1].push_back(a1);
    }
    ff(i,1,n)
    {
        int p=kk[i].a;
        if(!vv[p])
        {
            nn=p;
            vv[p]=1;
            sum[p]=dfs(p,0);
        }
    }
    ff(i,1,n)
    {

        if(vis[kk[i].a]!=vis[kk[i].b]||vis[kk[i].a]!=sum[kk[i].a]-1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000],vv[200000],sum[200000],nn;
typedef struct hu
{
    int a,b;
};
hu kk[200000];
vector<int>edg[200000];
int dfs(int node,int deep)
{
    int flag=0,re=0;
    for(int i=0;i<edg[node].size();i++)
    {
        int nodenow=edg[node][i];
        if(!vv[nodenow])
        {
            vv[nodenow]=1;
            int kt=dfs(nodenow,deep+1);
            vv[nodenow]=0;
            if(kt>sum[nodenow])
            sum[nodenow]=kt;
            re=sum[nodenow];
            flag=1;
        }
    }
    if(!flag)
    {
        return deep+1;
    }
    return re;
}
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
        edg[a1].push_back(b1);
        edg[b1].push_back(a1);
    }
    ff(i,1,n)
    {
        int p=kk[i].a;
        if(!sum[p])
        {
            nn=p;
            vv[p]=1;
            sum[p]=dfs(p,0);
        }
    }
    ff(i,1,n)
    {

        if(vis[kk[i].a]!=vis[kk[i].b]||vis[kk[i].a]!=sum[kk[i].a]-1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <string>//c++
#include <string.h>//c
#include <math.h>
#include <iostream>
#include <set>
#include <map>
#include <sstream>
#define ff(i,x,y)for(int i=x;i<=y;i++)
#define fs(i,x,y)for(int i=x;i>=y;i--)
#define maxn 20
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
//set<int>::iterator set_stater
//typedef pair<int,int> pii;
using namespace std;
int m,n,vis[200000],vv[200000],sum[200000],nn;
typedef struct hu
{
    int a,b;
};
hu kk[200000];
vector<int>edg[200000];
int dfs(int node,int deep)
{
    int flag=0,re=0;
    for(int i=0;i<edg[node].size();i++)
    {
        int nodenow=edg[node][i];
        if(!vv[nodenow])
        {
            vv[nodenow]=1;
            int kt=dfs(nodenow,deep+1);
            if(kt<=vis[nodenow])
            vv[nodenow]=0;
            if(kt>sum[nodenow])
            sum[nodenow]=kt;
            re=sum[nodenow];
            flag=1;
        }
    }
    if(!flag)
    {
        return deep+1;
    }
    return re;
}
int main()
{
    scanf("%d%d",&m,&n);
    int a1,b1;
    ff(i,1,n)
    {
        scanf("%d%d",&a1,&b1);
        kk[i].a=a1;
        kk[i].b=b1;
        vis[a1]++;
        vis[b1]++;
        edg[a1].push_back(b1);
        edg[b1].push_back(a1);
    }
    ff(i,1,n)
    {
        int p=kk[i].a;
        if(!sum[p])
        {
            nn=p;
            vv[p]=1;
            sum[p]=dfs(p,0);
        }
    }
    ff(i,1,n)
    {

        if(vis[kk[i].a]!=vis[kk[i].b]||vis[kk[i].a]!=sum[kk[i].a]-1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
	LL sum = 1;
	for (int i = 1; i <= x; i++) sum *= 16;
	return sum;
}

LL f(char ch[], LL x)
{
	LL sum = 0;
	memset(visit, 0, sizeof visit);
	for (int i = 0; i < 8; i++)
	{
		LL xx = my(8 - i - 1);
		int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
		for (int j = 0; j < k; j++) visit[j] += xx;
		x -= k*xx;
		visit[k] += x;
		if (k)
		{
			for (int j = 0; j < 16; j++) visit[j] += xx / 16;
		}
	}
	for (int i = 0; i < 16; i++)
		sum += visit[i] * val[i];
	return sum;
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%lld%s", &n, ch1);
		a = 0;
		LL ans;
		for (int i = 0; i < 8; i++)
		{
			if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
			else a = a * 16 + ch1[i] - 'A' + 10;
		}
		LL ans1 = f(ch1, a + 1);
		b = a + n - 1;
		if (b <= my(8) - 1)
		{
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans=ans2 - ans1;
		}
		else
		{
			b = b -my(8);
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans = ans2 +f("FFFFFFFF",my(8))- ans1;
		}
		for (int i = 0; i < 8; i++)
		{
			int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
			ans += val[k];
		}
		printf("%lld\n", ans);
	}
	return 0;
}*/

int f[150005],sum[150005],cnt[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i,cnt[i]=1;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			if (aa != bb)
			{
				f[aa] = bb;
				sum[bb] = sum[aa] + sum[bb] + 1;
				cnt[bb] = cnt[bb] + cnt[aa];
			}
		}
		int flag = 1;
		for (int i = 1; i <= n; i++)
		{
			int aa = Find(i);
			if (aa == i)
			{
				if (sum[aa] != cnt[aa] * (cnt[aa] - 1) / 2)
					flag = 0;
			}
		}
		if (flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
	LL sum = 1;
	for (int i = 1; i <= x; i++) sum *= 16;
	return sum;
}

LL f(char ch[], LL x)
{
	LL sum = 0;
	memset(visit, 0, sizeof visit);
	for (int i = 0; i < 8; i++)
	{
		LL xx = my(8 - i - 1);
		int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
		for (int j = 0; j < k; j++) visit[j] += xx;
		x -= k*xx;
		visit[k] += x;
		if (k)
		{
			for (int j = 0; j < 16; j++) visit[j] += xx / 16;
		}
	}
	for (int i = 0; i < 16; i++)
		sum += visit[i] * val[i];
	return sum;
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%lld%s", &n, ch1);
		a = 0;
		LL ans;
		for (int i = 0; i < 8; i++)
		{
			if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
			else a = a * 16 + ch1[i] - 'A' + 10;
		}
		LL ans1 = f(ch1, a + 1);
		b = a + n - 1;
		if (b <= my(8) - 1)
		{
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans=ans2 - ans1;
		}
		else
		{
			b = b -my(8);
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans = ans2 +f("FFFFFFFF",my(8))- ans1;
		}
		for (int i = 0; i < 8; i++)
		{
			int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
			ans += val[k];
		}
		printf("%lld\n", ans);
	}
	return 0;
}*/

int f[150005],sum[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			if (aa != bb) f[aa] = bb;
		}
		for (int i = 1; i <= n; i++) sum[Find(i)]++;
		int sum1 = 0;
		for (int i = 1; i <= n; i++)
		{
			if(Find(i)==i)
			{
				sum1 += sum[i] * (sum[i] - 1) / 2;
			}
		}
		if (sum1==m) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
	LL sum = 1;
	for (int i = 1; i <= x; i++) sum *= 16;
	return sum;
}

LL f(char ch[], LL x)
{
	LL sum = 0;
	memset(visit, 0, sizeof visit);
	for (int i = 0; i < 8; i++)
	{
		LL xx = my(8 - i - 1);
		int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
		for (int j = 0; j < k; j++) visit[j] += xx;
		x -= k*xx;
		visit[k] += x;
		if (k)
		{
			for (int j = 0; j < 16; j++) visit[j] += xx / 16;
		}
	}
	for (int i = 0; i < 16; i++)
		sum += visit[i] * val[i];
	return sum;
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%lld%s", &n, ch1);
		a = 0;
		LL ans;
		for (int i = 0; i < 8; i++)
		{
			if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
			else a = a * 16 + ch1[i] - 'A' + 10;
		}
		LL ans1 = f(ch1, a + 1);
		b = a + n - 1;
		if (b <= my(8) - 1)
		{
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans=ans2 - ans1;
		}
		else
		{
			b = b -my(8);
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans = ans2 +f("FFFFFFFF",my(8))- ans1;
		}
		for (int i = 0; i < 8; i++)
		{
			int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
			ans += val[k];
		}
		printf("%lld\n", ans);
	}
	return 0;
}*/

int f[150005],sum[150005],cnt[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i,cnt[i]=1;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			if (aa != bb)
			{
				f[aa] = bb;
				cnt[bb] = cnt[bb] + cnt[aa];
				sum[bb] = sum[aa] + sum[bb] + 1;
			}
			else sum[aa]++;
		}
		int flag = 1;
		for (int i = 1; i <= n; i++)
		{
			int aa = Find(i);
			if (aa == i)
			{
				if (sum[aa] != cnt[aa] * (cnt[aa] - 1) / 2)
					flag = 0;
			}
		}
		if (flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
	LL sum = 1;
	for (int i = 1; i <= x; i++) sum *= 16;
	return sum;
}

LL f(char ch[], LL x)
{
	LL sum = 0;
	memset(visit, 0, sizeof visit);
	for (int i = 0; i < 8; i++)
	{
		LL xx = my(8 - i - 1);
		int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
		for (int j = 0; j < k; j++) visit[j] += xx;
		x -= k*xx;
		visit[k] += x;
		if (k)
		{
			for (int j = 0; j < 16; j++) visit[j] += xx / 16;
		}
	}
	for (int i = 0; i < 16; i++)
		sum += visit[i] * val[i];
	return sum;
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%lld%s", &n, ch1);
		a = 0;
		LL ans;
		for (int i = 0; i < 8; i++)
		{
			if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
			else a = a * 16 + ch1[i] - 'A' + 10;
		}
		LL ans1 = f(ch1, a + 1);
		b = a + n - 1;
		if (b <= my(8) - 1)
		{
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans=ans2 - ans1;
		}
		else
		{
			b = b -my(8);
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans = ans2 +f("FFFFFFFF",my(8))- ans1;
		}
		for (int i = 0; i < 8; i++)
		{
			int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
			ans += val[k];
		}
		printf("%lld\n", ans);
	}
	return 0;
}*/

int f[150005],sum[150005],cnt[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i,cnt[i]=1;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			f[aa] = bb;
			sum[bb] = sum[aa] + sum[bb] + 1;
			cnt[bb] = cnt[bb] + cnt[aa];
		}
		int flag = 1;
		for (int i = 1; i <= n; i++)
		{
			int aa = Find(i);
			if (aa == i)
			{
				if (sum[aa] != cnt[aa] * (cnt[aa] - 1) / 2)
					flag = 0;
			}
		}
		if (flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
LL sum = 1;
for (int i = 1; i <= x; i++) sum *= 16;
return sum;
}

LL f(char ch[], LL x)
{
LL sum = 0;
memset(visit, 0, sizeof visit);
for (int i = 0; i < 8; i++)
{
LL xx = my(8 - i - 1);
int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
for (int j = 0; j < k; j++) visit[j] += xx;
x -= k*xx;
visit[k] += x;
if (k)
{
for (int j = 0; j < 16; j++) visit[j] += xx / 16;
}
}
for (int i = 0; i < 16; i++)
sum += visit[i] * val[i];
return sum;
}

int main()
{
int t;
scanf("%d", &t);
while (t--)
{
scanf("%lld%s", &n, ch1);
a = 0;
LL ans;
for (int i = 0; i < 8; i++)
{
if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
else a = a * 16 + ch1[i] - 'A' + 10;
}
LL ans1 = f(ch1, a + 1);
b = a + n - 1;
if (b <= my(8) - 1)
{
LL bb = b;
for (int i = 7; i >= 0; i--)
{
int k = bb % 16;
ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
bb /= 16;
}
LL ans2 = f(ch2, b + 1);
ans=ans2 - ans1;
}
else
{
b = b -my(8);
LL bb = b;
for (int i = 7; i >= 0; i--)
{
int k = bb % 16;
ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
bb /= 16;
}
LL ans2 = f(ch2, b + 1);
ans = ans2 +f("FFFFFFFF",my(8))- ans1;
}
for (int i = 0; i < 8; i++)
{
int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
ans += val[k];
}
printf("%lld\n", ans);
}
return 0;
}*/

int f[150005], ;
LL sum[150005], cnt[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i, cnt[i] = 1;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			if (aa != bb)
			{
				f[aa] = bb;
				cnt[bb] = cnt[bb] + cnt[aa];
				sum[bb] = sum[aa] + sum[bb] + 1;
			}
			else sum[aa]++;
		}
		int flag = 1;
		for (int i = 1; i <= n; i++)
		{
			int aa = Find(i);
			if (aa == i)
			{
				if (sum[aa] != cnt[aa] * (cnt[aa] - 1) / 2)
					flag = 0;
			}
		}
		if (flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
	LL sum = 1;
	for (int i = 1; i <= x; i++) sum *= 16;
	return sum;
}

LL f(char ch[], LL x)
{
	LL sum = 0;
	memset(visit, 0, sizeof visit);
	for (int i = 0; i < 8; i++)
	{
		LL xx = my(8 - i - 1);
		int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
		for (int j = 0; j < k; j++) visit[j] += xx;
		x -= k*xx;
		visit[k] += x;
		if (k)
		{
			for (int j = 0; j < 16; j++) visit[j] += xx / 16;
		}
	}
	for (int i = 0; i < 16; i++)
		sum += visit[i] * val[i];
	return sum;
}

int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%lld%s", &n, ch1);
		a = 0;
		LL ans;
		for (int i = 0; i < 8; i++)
		{
			if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
			else a = a * 16 + ch1[i] - 'A' + 10;
		}
		LL ans1 = f(ch1, a + 1);
		b = a + n - 1;
		if (b <= my(8) - 1)
		{
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans=ans2 - ans1;
		}
		else
		{
			b = b -my(8);
			LL bb = b;
			for (int i = 7; i >= 0; i--)
			{
				int k = bb % 16;
				ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
				bb /= 16;
			}
			LL ans2 = f(ch2, b + 1);
			ans = ans2 +f("FFFFFFFF",my(8))- ans1;
		}
		for (int i = 0; i < 8; i++)
		{
			int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
			ans += val[k];
		}
		printf("%lld\n", ans);
	}
	return 0;
}*/

int f[150005],sum[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			if (aa != bb) f[aa] = bb;
		}
		for (int i = 1; i <= n; i++) sum[Find(i)]++;
		int sum1 = 0;
		for (int i = 1; i <= n; i++)
		{
			if(Find(i)==i)
			{
				sum1 += sum[i] * (sum[i] - 1) / 2;
			}
		}
		if (sum1!=m) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>

using namespace std;

#define LL long long
const int INF = 0x3f3f3f3f;

/*char ch1[20], ch2[20];
LL n, a, b, visit[20];
LL val[16] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 6, 5, 4, 5, 5, 4 };

LL my(int x)
{
LL sum = 1;
for (int i = 1; i <= x; i++) sum *= 16;
return sum;
}

LL f(char ch[], LL x)
{
LL sum = 0;
memset(visit, 0, sizeof visit);
for (int i = 0; i < 8; i++)
{
LL xx = my(8 - i - 1);
int k = ch[i] >= '0'&&ch[i] <= '9' ? ch[i] - '0' : ch[i] - 'A' + 10;
for (int j = 0; j < k; j++) visit[j] += xx;
x -= k*xx;
visit[k] += x;
if (k)
{
for (int j = 0; j < 16; j++) visit[j] += xx / 16;
}
}
for (int i = 0; i < 16; i++)
sum += visit[i] * val[i];
return sum;
}

int main()
{
int t;
scanf("%d", &t);
while (t--)
{
scanf("%lld%s", &n, ch1);
a = 0;
LL ans;
for (int i = 0; i < 8; i++)
{
if (ch1[i] >= '0'&&ch1[i] <= '9') a = a * 16 + ch1[i] - '0';
else a = a * 16 + ch1[i] - 'A' + 10;
}
LL ans1 = f(ch1, a + 1);
b = a + n - 1;
if (b <= my(8) - 1)
{
LL bb = b;
for (int i = 7; i >= 0; i--)
{
int k = bb % 16;
ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
bb /= 16;
}
LL ans2 = f(ch2, b + 1);
ans=ans2 - ans1;
}
else
{
b = b -my(8);
LL bb = b;
for (int i = 7; i >= 0; i--)
{
int k = bb % 16;
ch2[i] = k >= 0 && k <= 9 ? k + '0' : k - 10 + 'A';
bb /= 16;
}
LL ans2 = f(ch2, b + 1);
ans = ans2 +f("FFFFFFFF",my(8))- ans1;
}
for (int i = 0; i < 8; i++)
{
int k = ch1[i] >= '0'&&ch1[i] <= '9' ? ch1[i] - '0' : ch1[i] - 'A' + 10;
ans += val[k];
}
printf("%lld\n", ans);
}
return 0;
}*/

int f[150005];
LL sum[150005], cnt[150005];
int n, m;

int Find(int x)
{
	if (x == f[x]) return x;
	else return f[x] = Find(f[x]);
}

int main()
{
	while (~scanf("%d%d", &n, &m))
	{
		for (int i = 1; i <= n; i++) f[i] = i, cnt[i] = 1;
		memset(sum, 0, sizeof sum);
		int a, b;
		for (int i = 0; i < m; i++)
		{
			scanf("%d%d", &a, &b);
			int aa = Find(a), bb = Find(b);
			if (aa != bb)
			{
				f[aa] = bb;
				cnt[bb] = cnt[bb] + cnt[aa];
				sum[bb] = sum[aa] + sum[bb] + 1;
			}
			else sum[aa]++;
		}
		int flag = 1;
		for (int i = 1; i <= n; i++)
		{
			int aa = Find(i);
			if (aa == i)
			{
				if (sum[aa] != cnt[aa] * (cnt[aa] - 1) / 2)
					flag = 0;
			}
		}
		if (flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 150022;
int n, m, used[N], k = 0;
vector<int> g[N];
set<int> ch[N];

void dfs(int v, int p){
    used[v] = 1;
    k++;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(p != to){
        if(k >= 2 && p != -1 && g[v].size() > 1){
            if(ch[p].count(to) == 0){
               // cout << p << ' ' << v << ' ' << to;
                cout << "NO";
                exit(0);
            }
        }
        if(!used[to]){
            dfs(to, v);
        }
        k--;
        }
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        ch[x].insert(y);
        ch[y].insert(x);
    }
    for(int i = 1; i <= n; i++){
        k = 0;
        if(!used[i]){
            dfs(i, -1);
        }
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 150022;
int n, m, used[N];
vector<int> g[N];
set<int> ch[N];

void dfs(int v, int p){
    used[v] = 1;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(p != -1){
            for(int j = 0; j < g[p].size(); j++){
                int z = g[p][j];
                if(z != v){
                    if(!ch[z].count(v)){
                        cout << "NO";
                        exit(0);
                    }
                }
            }
        }
        if(!used[to])
            dfs(to, v);

    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        ch[x].insert(y);
        ch[y].insert(x);
    }
    for(int i = 1; i <= n; i++)
        if(!used[i])
            dfs(i, -1);
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 150022;
int n, m, used[N], k = 0;
vector<int> g[N];
set<int> ch[N];

void dfs(int v, int p){
    used[v] = 1;
    k++;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(p != to){
        if(k >= 2 && p != -1 && g[v].size() > 1){
            if(ch[p].count(to) == 0){
               // cout << p << ' ' << v << ' ' << to;
                cout << "NO";
                exit(0);
            }
        }
        if(!used[to]){
            dfs(to, v);
        }
        }
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        ch[x].insert(y);
        ch[y].insert(x);
    }
    for(int i = 1; i <= n; i++){
        k = 0;
        if(g[i].size() > 1)
            continue;
        if(!used[i]){
            dfs(i, -1);
        }
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 150022;
int n, m, used[N],k[N];
vector<int> g[N];
set<int> ch[N];

void dfs(int v, int p){
    used[v] = 1;
    k[v] = k[p] + 1;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(p != to){
        if(k[v] >= 2 && p != 0 && g[v].size() > 1){
            if(ch[p].count(to) == 0){
               // cout << p << ' ' << v << ' ' << to;
                cout << "NO";
                exit(0);
            }
        }
        if(!used[to]){
            dfs(to, v);
        }
        }
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        ch[x].insert(y);
        ch[y].insert(x);
    }
    for(int i = 1; i <= n; i++){
        if(!used[i]){
            dfs(i, 0);
        }
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 150022;
int n, m, used[N], k = 0;
vector<int> g[N];
set<int> ch[N];

void dfs(int v, int p){
    used[v] = 1;
    k++;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(p != to){
        if(k >= 2 && p != -1 && g[v].size() > 1){
            if(ch[p].count(to) == 0){
               // cout << p << ' ' << v << ' ' << to;
                cout << "NO";
                exit(0);
            }
        }
        if(!used[to]){
            dfs(to, v);
        }
        }
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        ch[x].insert(y);
        ch[y].insert(x);
    }
    for(int i = 1; i <= n; i++){
        k = 0;
        if(!used[i]){
            dfs(i, -1);
        }
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int inf = 1e9;
const int N = 150003;

long long used[N], cvert = 0, cedge = 0, n, m;
vector<int> g[N];

void dfs(int v){
    used[v] = 1;
    cvert++;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        cedge++;
        if(!used[to]){
            dfs(to);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i <= n; i++){
        cedge = 0;
        cvert = 0;
        if(!used[i]){
            dfs(i);
            cedge /= 2;
            if(cedge != cvert * (cvert - 1) / 2 && cvert > 2){
                cout << "NO";
                exit(0);
            }
        }
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int inf = 1e9;
const int N = 150003;

long long used[N], cvert = 0, cedge = 0, n, m;
vector<int> g[N];

void dfs(int v){
    used[v] = 1;
    cvert++;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        cedge++;
        if(!used[to]){
            dfs(to);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i <= n; i++){
        cedge = 0;
        cvert = 0;
        if(!used[i]){
            dfs(i);
            if(cedge != cvert * (cvert - 1) / 2 && cvert > 2){
                cout << "NO";
                exit(0);
            }
        }
    }
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 150022;
int n, m, used[N];
vector<int> g[N];
set<int> ch[N];

void dfs(int v, int p){
    used[v] = 1;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if(p != -1){
            for(int j = 0; j < g[v].size(); j++){
                int z = g[v][j];
                if(z != to)
                    if(!ch[z].count(to)){
                        cout << "NO";
                        exit(0);
                    }
            }
        }
        if(!used[to])
            dfs(to, v);

    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        ch[x].insert(y);
        ch[y].insert(x);
    }
    for(int i = 1; i <= n; i++)
        if(!used[i])
            dfs(i, -1);
    cout << "YES";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int inf = 1e9;
const int N = 150003;

int used[N], cvert = 0, cedge = 0, n, m;
vector<int> g[N];

void dfs(int v){
    used[v] = 1;
    cvert++;
    for(int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        cedge++;
        if(!used[to]){
            dfs(to);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i <= n; i++){
        cedge = 0;
        cvert = 0;
        if(!used[i]){
            dfs(i);
            cedge /= 2;
            if(cedge != cvert * (cvert - 1) / 2 && cvert > 2){
                cout << "NO";
                exit(0);
            }
        }
    }
    cout << "YES";
    return 0;
}


#include<stdio.h>
#include<string.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bitset>
#include<bits/c++io.h>
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1 | 1
#define MOD 100000000
using namespace std;
typedef long long LL;
const int size=150010;
const LL INF=1e9;
int a[size];
int dp[size];
int fa[size];
int ind[size];
int vis[size];
vector<int> q[size];
void init(int n)
{
    for(int i=1;i<=n;i++)
        fa[i]=i;
}
int find(int x)
{
    if(x==fa[x])
        return x;
    fa[x]=find(fa[x]);
    return fa[x];
}
void init(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    fa[fx]=fy;
}
bool flag;
void dfs(int x,int num)
{

    if(flag) return ;
    if(ind[x]!=num)
    {
        flag=1;
        return ;
    }
    if(vis[x]) return;
    int len=q[x].size();
    vis[x]=1;
    for(int i=0;i<len;i++)
    {
      int u=q[x][i];
      dfs(u,num);
    }

}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ind[x]++,ind[y]++;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    init(n);
    bool ans=0;
    for(int i=1;i<=n;i++)
    {
        if(find(i)==i)
        {
            int len=q[i].size();
            if(len==0) continue;
           flag=0;
           dfs(i,len);
           if(flag)
           {
               printf("NO\n");
               return 0;
           }
        }
    }
    printf("YES\n");
}


#include<stdio.h>
#include<string.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bitset>
#include<bits/c++io.h>
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1 | 1
#define MOD 100000000
using namespace std;
typedef long long LL;
const int size=150010;
const LL INF=1e9;
int a[size];
int dp[size];
int fa[size];
int ind[size];
int vis[size];
vector<int> q[size];
void init(int n)
{
    for(int i=1;i<=n;i++)
        fa[i]=i;
}
int find(int x)
{
    if(x==fa[x])
        return x;
    fa[x]=find(fa[x]);
    return fa[x];
}
void unit(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    fa[fx]=fy;
}
bool flag;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m); init(n);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ind[x]++,ind[y]++;
        unit(x,y);
    }

    for(int i=1;i<=n;i++)
    {
        int fx=find(i);
        a[fx]++;
    }
    for(int i=1;i<=n;i++)
    {
        int fx=find(i);
        if(a[fx]!=ind[i]+1)
        {
            printf("NO\n");
            return 0;
        }
    }
//    for(int i=1;i<=n;i++)
//        printf("%d ",a[i]);
    printf("YES\n");
//    for(int i=1;i<=n;i++)
 }


#include<stdio.h>
#include<string.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bitset>
#include<bits/c++io.h>
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1 | 1
#define MOD 100000000
using namespace std;
typedef long long LL;
const int size=150010;
const LL INF=1e9;
int a[size];
int vis[size];
int dp[size];
int b[size];
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;i++)
  {
      int x,y;
      scanf("%d%d",&x,&y);
      vis[x]++,vis[y]++;
  }
  int flag=0;
  int odd=0,even=0;
  for(int i=1;i<=n;i++)
  {
      if(vis[i]>2&&vis[i]%2)
      {
          printf("NO\n");
          return 0;
      }
      if(vis[i]==1)
        {
            odd++;
        }
        else
            even++;
  }
  odd=odd%2,even=even%2;
  if(!odd&&!even)
  printf("YES\n");
  else
    printf("NO\n");
}


#include<stdio.h>
#include<string.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bitset>
#include<bits/c++io.h>
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1 | 1
#define MOD 100000000
using namespace std;
typedef long long LL;
const int size=150010;
const LL INF=1e9;
int a[size];
int dp[size];
int fa[size];
int ind[size];
int vis[size];
vector<int> q[size];
void init(int n)
{
    for(int i=1;i<=n;i++)
        fa[i]=i;
}
int find(int x)
{
    if(x==fa[x])
        return x;
    fa[x]=find(fa[x]);
    return fa[x];
}
void init(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    fa[fx]=fy;
}
bool flag;
int step;
void dfs(int x,int num,int step)
{
    if(step>num+1)
    {
//        printf("%d %d\n",step,num);
        flag=1;return ;
    }
    if(flag) return ;
    if(ind[x]!=num)
    {
        flag=1;
        return ;
    }
    if(vis[x])
    {
        return;
    }
    int len=q[x].size();
    vis[x]=1;
    for(int i=0;i<len;i++)
    {
      int u=q[x][i];
      dfs(u,num,step+1);
    }
//    step++;

}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ind[x]++,ind[y]++;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    init(n);
    bool ans=0;
    for(int i=1;i<=n;i++)
    {
        if(find(i)==i)
        {
            int len=q[i].size();
            if(len==0) continue;
           flag=0;
           dfs(i,len,0);
//           printf("step==%d\n",step);
           if(flag)
           {
               printf("NO\n");
               return 0;
           }
        }
    }
    printf("YES\n");
}


#include<stdio.h>
#include<string.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bitset>
#include<bits/c++io.h>
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1 | 1
#define MOD 100000000
using namespace std;
typedef long long LL;
const int size=150010;
const LL INF=1e9;
int a[size];
int dp[size];
int fa[size];
int ind[size];
int vis[size];
vector<int> q[size];
void init(int n)
{
    for(int i=1;i<=n;i++)
        fa[i]=i;
}
int find(int x)
{
    if(x==fa[x])
        return x;
    fa[x]=find(fa[x]);
    return fa[x];
}
void init(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    fa[fx]=fy;
}
bool flag;
void dfs(int x,int num)
{
    if(vis[x]) return;
    if(flag) return ;
    if(ind[x]!=num)
    {
        flag=1;
        return ;
    }
    int len=q[x].size();
    vis[x]=1;
    for(int i=0;i<len;i++)
    {
      int u=q[x][i];
      dfs(u,num);
    }
    vis[x]=0;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ind[x]++,ind[y]++;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    init(n);
    bool ans=0;
    for(int i=1;i<=n;i++)
    {
        if(fa[i]==i)
        {
            int len=q[i].size();
            if(len==0) continue;
           flag=0;
           dfs(i,len);
           if(flag)
           {
               printf("NO\n");
               return 0;
           }
        }
    }
    printf("YES\n");
}


#include<stdio.h>
#include<string.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bitset>
#include<bits/c++io.h>
#define CLR(a,b) memset((a),(b),sizeof((a)))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1 | 1
#define MOD 100000000
using namespace std;
typedef long long LL;
const int size=150010;
const LL INF=1e9;
int a[size];
int dp[size];
int fa[size];
int ind[size];
int vis[size];
vector<int> q[size];
void init(int n)
{
    for(int i=1;i<=n;i++)
        fa[i]=i;
}
int find(int x)
{
    if(x==fa[x])
        return x;
    fa[x]=find(fa[x]);
    return fa[x];
}
void init(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    fa[fx]=fy;
}
bool flag;
void dfs(int x,int num)
{
    if(vis[x]) return;
    if(flag) return ;
    if(ind[x]!=num)
    {
        flag=1;
        return ;
    }
    int len=q[x].size();
    vis[x]=1;
    for(int i=0;i<len;i++)
    {
      int u=q[x][i];
      dfs(u,num);
    }
    vis[x]=0;
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ind[x]++,ind[y]++;
        q[x].push_back(y);
        q[y].push_back(x);
    }
    init(n);
    bool ans=0;
    for(int i=1;i<=n;i++)
    {
        if(find(i)==i)
        {
            int len=q[i].size();
            if(len==0) continue;
           flag=0;
           dfs(i,len);
           if(flag)
           {
               printf("NO\n");
               return 0;
           }
        }
    }
    printf("YES\n");
}


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

int n,m;
vector <bool> visited;
vector <bool> v1;
vector <vector <int> > a;
int nodes;
bool flag=true;

int dfs(int i){
    int c=0,j;
    if(visited[i]==false){
        visited[i]=true;
        c++;

        for(j=0;j<a[i].size();j++){
            if(visited[a[i][j]]==false){
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}
void dfs1(int i){
    int j;
    if(v1[i]==false){
        v1[i]=true;
        for(j=0;j<a[i].size();j++){
            if(v1[a[i][j]]==false){

            if((a[i].size()+1)!=nodes){
                flag=false;
                return;
            }
            dfs1(a[i][j]);
        }
        }
    }
}

/* Driver program to test above functions*/
int main()
{   int i,x,y,ans=0;
    cin>>n>>m;

    a.resize(n+1);
    visited.resize(n+1);
    v1.resize(n+1);

    for(i=0;i<m;i++){
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    for(i=1;i<=n;i++){
        visited[i]=false;
         v1[i]=false;
    }

    for(i=1;i<=n;i++){
        nodes=dfs(i);
        dfs1(i);

    }

    if(flag==true){
        cout<<"YES";
    }
    else
    cout<<"NO";

	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int branch;
vector <vector <int> > a;
vector <bool> visited;

int dfs(int i){
    int c=1;
    int j;
    if(visited[i]==false){

        visited[i]=true;
        for(j=0;j<a[i].size();j++){

            if(visited[a[i][j]]==false){
                //branch++;
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}

int main()
{
	int n,m,i,x,y,ans=0;
	cin>>n>>m;

	a.resize(n+1);
	visited.resize(n+1);

	for(i=0;i<n;i++){
	    cin>>x>>y;
	    a[x].push_back(y);
	    a[y].push_back(x);
	}
	int nodes;
	for(i=1;i<=n;i++){
	    //branch=0;
	    nodes=dfs(i);

	    if(nodes>2){
	        ans+=nodes*(nodes-1)/2;
	    }
	    if(nodes==2){
	        ans+=1;
	    }
	   // cout<<nodes<<" "<<ans<<endl;
	   // cout<<branch<<" "<<nodes<<endl;
	    /*if(branch!=(nodes*(nodes-1)/2)){
	        cout<<"NO";
	        return 0;
	    }*/

	}
	//cout<<"m is"<<m;
	if(ans==m)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

vector <vector <int> > a;
vector <bool> visited;

int dfs(int i){
    int c=0;
    int j;
    if(visited[i]==false){
        c=1;
        visited[i]=true;
        for(j=0;j<a[i].size();j++){

            if(visited[a[i][j]]==false){

                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}

int main()
{
	int n,m,i,x,y,ans=0;
	cin>>n>>m;

	a.resize(n+1);
	visited.resize(n+1);

	for(i=0;i<m;i++){
	    cin>>x>>y;
	    a[x].push_back(y);
	    a[y].push_back(x);
	}
	int nodes;
	for(i=1;i<=n;i++){
	    //branch=0;
	    nodes=dfs(i);

	        ans+=nodes*(nodes-1)/2;

	}
	//cout<<"m is"<<m;
	if(ans==m)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

vector <vector <int> > a;
vector <bool> visited;

int dfs(int i){
    int c=1;
    int j;
    if(visited[i]==false){

        visited[i]=true;
        for(j=0;j<a[i].size();j++){

            if(visited[a[i][j]]==false){
                //branch++;
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}

int main()
{
	int n,m,i,x,y,ans=0;
	cin>>n>>m;

	a.resize(n+1);
	visited.resize(n+1);

	for(i=0;i<m;i++){
	    cin>>x>>y;
	    a[x].push_back(y);
	    a[y].push_back(x);
	}
	int nodes;
	for(i=1;i<=n;i++){
	    //branch=0;
	    nodes=dfs(i);

	    if(nodes>2){
	        ans+=nodes*(nodes-1)/2;
	    }
	    if(nodes==2){
	        ans+=1;
	    }
	   // cout<<nodes<<" "<<ans<<endl;
	   // cout<<branch<<" "<<nodes<<endl;
	    /*if(branch!=(nodes*(nodes-1)/2)){
	        cout<<"NO";
	        return 0;
	    }*/

	}
	//cout<<"m is"<<m;
	if(ans==m)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

vector <vector <int> > a;
vector <bool> visited;

long long int dfs(int i){
    long long int c=1;
    int j;
    if(visited[i]==false){

        visited[i]=true;
        for(j=0;j<a[i].size();j++){

            if(visited[a[i][j]]==false){
                //branch++;
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}

int main()
{
	int n,m,i,x,y;
	long long ans=0;
	cin>>n>>m;

	a.resize(n+1);
	visited.resize(n+1);

	for(i=0;i<m;i++){
	    cin>>x>>y;
	    a[x].push_back(y);
	    a[y].push_back(x);
	}
	long long int nodes;
	for(i=1;i<=n;i++){
	    //branch=0;
	    nodes=dfs(i);

	    if(nodes>2){
	        ans+=nodes*(nodes-1)/2;
	    }
	    if(nodes==2){
	        ans+=1;
	    }
	   // cout<<nodes<<" "<<ans<<endl;
	   // cout<<branch<<" "<<nodes<<endl;
	    /*if(branch!=(nodes*(nodes-1)/2)){
	        cout<<"NO";
	        return 0;
	    }*/

	}
	//cout<<"m is"<<m;
	if(ans==m)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

vector <vector <int> > a;
vector <bool> visited;

int dfs(int i){
    int c=0;
    int j;
    if(visited[i]==false){
        c=1;
        visited[i]=true;
        for(j=0;j<a[i].size();j++){

            if(visited[a[i][j]]==false){
                //branch++;
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}

int main()
{
	int n,m,i,x,y,ans=0;
	cin>>n>>m;

	a.resize(n+1);
	visited.resize(n+1);

	for(i=0;i<m;i++){
	    cin>>x>>y;
	    a[x].push_back(y);
	    a[y].push_back(x);
	}
	int nodes;
	for(i=1;i<=n;i++){
	    //branch=0;
	    nodes=dfs(i);

	    if(nodes>2){
	        ans+=nodes*(nodes-1)/2;
	    }
	    if(nodes==2){
	        ans+=1;
	    }
	   // cout<<nodes<<" "<<ans<<endl;
	   // cout<<branch<<" "<<nodes<<endl;
	    /*if(branch!=(nodes*(nodes-1)/2)){
	        cout<<"NO";
	        return 0;
	    }*/

	}
	//cout<<"m is"<<m;
	if(ans==m)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


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

int n,m;
vector <bool> visited;
vector <bool> v1;
vector <vector <int> > a;
int nodes;
bool flag=true;

int dfs(int i){
    int c=0,j;
    if(visited[i]==false){
        visited[i]=true;
        c++;

        for(j=0;j<a[i].size();j++){
            if(visited[a[i][j]]==false){
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}
void dfs1(int i){
    int j;
    //cout<<i<<" "<<a[i].size()<<" "<<nodes<<endl;
    if((a[i].size()+1)!=nodes){
                flag=false;
                return;
            }
    if(v1[i]==false){
        v1[i]=true;
        for(j=0;j<a[i].size();j++){
            if(v1[a[i][j]]==false){

            dfs1(a[i][j]);
        }
        }
    }
}

/* Driver program to test above functions*/
int main()
{   int i,x,y,ans=0;
    cin>>n>>m;

    a.resize(n+1);
    visited.resize(n+1);
    v1.resize(n+1);

    for(i=0;i<m;i++){
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    for(i=1;i<=n;i++){
        visited[i]=false;
         v1[i]=false;
    }

    for(i=1;i<=n;i++){
        if(visited[i]==false){
        nodes=dfs(i);
        //cout<<i<<" "<<nodes<<endl;
        dfs1(i);}

    }

    if(flag==true){
        cout<<"YES";
    }
    else
    cout<<"NO";

	return 0;
}


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

vector <vector <int> > a;
vector <bool> visited;

int dfs(int i){
    int c=1;
    int j;
    if(visited[i]==false){

        visited[i]=true;
        for(j=0;j<a[i].size();j++){

            if(visited[a[i][j]]==false){
                //branch++;
                c=c+dfs(a[i][j]);
            }
        }
    }
    return c;
}

int main()
{
	int n,m,i,x,y;
	long long int ans=0;
	cin>>n>>m;

	a.resize(n+1);
	visited.resize(n+1);

	for(i=0;i<m;i++){
	    cin>>x>>y;
	    a[x].push_back(y);
	    a[y].push_back(x);
	}
	int nodes;
	for(i=1;i<=n;i++){
	    //branch=0;
	    nodes=dfs(i);

	    if(nodes>2){
	        ans+=nodes*(nodes-1)/2;
	    }
	    if(nodes==2){
	        ans+=1;
	    }
	   // cout<<nodes<<" "<<ans<<endl;
	   // cout<<branch<<" "<<nodes<<endl;
	    /*if(branch!=(nodes*(nodes-1)/2)){
	        cout<<"NO";
	        return 0;
	    }*/

	}
	//cout<<"m is"<<m;
	if(ans==m)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define scan(x) scanf("%lld",&x)
#define MAX 100005
#define INF 1000000000000000007ll
#define mod 1000000007
#define pii pair<int,int>
#define hashmod 300007
#define hashmod1 300023
vector<int> adj[150005];
int visit[150005];
int deg[150005];
pair<int,int> dfs(int s)
{
   // cout<<s<<"\n";
    int a=1,b=deg[s];
    visit[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        if(visit[adj[s][i]]==0)
        {
            pair<int,int > p=dfs(adj[s][i]);
            a+=p.first;
            b+=p.second;
        }
    }
    return mp(a,b);
}
int main()
{
   // freopen("C:\\Users\\watson\\Documents\\input.txt","r",stdin);
   // freopen("C:\\Users\\watson\\Documents\\output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m,u,v;
    cin>>n>>m;

    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        deg[u]++;
        deg[v]++;
    }

    for(int i=1;i<=n;i++)
    {
        if(!visit[i])
        {
            pair<int,int> a=dfs(i);
            if((a.first*(a.first-1))==a.second)
                continue;
            else
            {
                cout<<"NO";
                return 0;
            }
        }
    }
    cout<<"YES";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define scan(x) scanf("%lld",&x)
#define MAX 100005
#define INF 1000000000000000007ll
#define mod 1000000007
#define pii pair<ll,ll>
#define hashmod 300007
#define hashmod1 300023
vector<ll> adj[150005];
ll visit[150005];
ll deg[150005];
pair<ll,ll> dfs(ll s)
{
   // cout<<s<<"\n";
    ll a=1,b=deg[s];
    visit[s]=1;
    for(ll i=0;i<adj[s].size();i++)
    {
        if(visit[adj[s][i]]==0)
        {
            pair<ll,ll > p=dfs(adj[s][i]);
            a+=p.first;
            b+=p.second;
        }
    }
    return mp(a,b);
}
int main()
{
  //  freopen("C:\\Users\\watson\\Documents\\input.txt","r",stdin);
   // freopen("C:\\Users\\watson\\Documents\\output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m,u,v;
    cin>>n>>m;

    for(ll i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        deg[u]++;
        deg[v]++;
    }

    for(ll i=1;i<=n;i++)
    {
        if(!visit[i])
        {
            pair<ll,ll> a=dfs(i);
            if((a.first*(a.first-1))==a.second)
                continue;
            else
            {
                cout<<"NO";
                return 0;
            }
        }
    }
    cout<<"YES";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define scan(x) scanf("%lld",&x)
#define MAX 100005
#define INF 1000000000000000007ll
#define mod 1000000007
#define pii pair<int,int>
#define hashmod 300007
#define hashmod1 300023
vector<int> adj [150005];
int visit[150005];
bool dfs(int s,int p,int d)
{
    if(d==3)
    {
        if(s==p)
          return true;
        else
          return false;
    }
    visit[s]=1;
    bool a=1;
    for(int i=0;i<adj[s].size();i++)
    {
        if(visit[adj[s][i]]==0)
        {
            a=a&dfs(adj[s][i],p,d+1);
        }
    }
    return a;
}
int main()
{
    //freopen("C:\\Users\\watson\\Documents\\input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    int u,v;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++)
    {
        if(visit[i]==0)
        {
            bool a=dfs(i,i,0);
            if(a==false)
            {
                cout<<"NO";
                return 0;
            }
        }
    }
    cout<<"YES";
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define scan(x) scanf("%lld",&x)
#define MAX 100005
#define INF 1000000000000000007ll
#define mod 1000000007
#define pii pair<int,int>
#define hashmod 300007
#define hashmod1 300023
vector<int> adj[150005];
int visit[150005];
int deg[150005];
pair<int,int> dfs(int s)
{
   // cout<<s<<"\n";
    int a=1,b=deg[s];
    visit[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        if(visit[adj[s][i]]==0)
        {
            pair<int,int > p=dfs(adj[s][i]);
            a+=p.first;
            b+=p.second;
        }
    }
    return mp(a,b);
}
int main()
{
   // freopen("C:\\Users\\watson\\Documents\\input.txt","r",stdin);
   // freopen("C:\\Users\\watson\\Documents\\output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m,u,v;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        deg[u]++;
        deg[v]++;
    }

    for(int i=1;i<=n;i++)
    {
        if(!visit[i])
        {
            pair<int,int> a=dfs(i);
            if((a.first*(a.first-1))/2==a.second/2)
                continue;
            else
            {
                cout<<"NO";
                return 0;
            }
        }
    }
    cout<<"YES";
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150006;

vector<int> node[maxn];
int vis[maxn];

bool check(int u, int id, int cur){
    if(cur>node[u].size()) return false;
    bool ret = true;
    for(int i=0; i<node[u].size() && ret; i++){
        int v = node[u][i];
        if(!vis[v]){
            vis[v]=id;
            if(node[u].size()!=node[v].size()) return false;
            ret = check(v, id, cur+1);
        }else if(vis[u]!=vis[v]){
            return false;
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    int u, v;
    for(int i=0; i<m; i++){
        cin>>u>>v;
        node[u].push_back(v);
        node[v].push_back(u);
    }
    bool ans=true;
    for(int i=0; i<n && ans; i++){
        if(!vis[i]){
            vis[i]=1;
            ans = check(i, 1, 1);
        }
    }
    cout << (ans?"YES":"NO") << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150006;

vector<int> node[maxn];
int vis[maxn];

bool check(int u, int id, int cur){
    if(cur>node[u].size()) return false;
    bool ret = true;
    for(int i=0; i<node[u].size() && ret; i++){
        int v = node[u][i];
        if(!vis[v]){
            if(!cur) vis[v]=id;
            if(node[u].size()!=node[v].size()) return false;
            ret = check(v, id, cur+1);
        }else if(vis[u]!=vis[v]){
            return false;
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    int u, v;
    for(int i=0; i<m; i++){
        cin>>u>>v;
        node[u].push_back(v);
        node[v].push_back(u);
    }
    bool ans=true;
    for(int i=0; i<n && ans; i++){
        if(!vis[i]){
            vis[i]=1;
            ans = check(i, 1, 0);
        }
    }
    cout << (ans?"YES":"NO") << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150006;

vector<int> node[maxn];
int mark[maxn];
bool vis[maxn];
bool check(int u, int id, int cur){
    if(cur>node[u].size()) return false;
    bool ret = true;
    if(cur==0){
        for(int i=0; i<node[u].size(); i++){
            int v = node[u][i];
            if(mark[v] && mark[v]!=id) return false;
            mark[v]=id;
        }
    }
//    cout << u << " " << id << " " << cur << endl;
    for(int i=0; i<node[u].size() && ret; i++){
        int v = node[u][i];
        if(mark[u]!=mark[v]) return false;
        if(!vis[v]){
            if(node[u].size()!=node[v].size()) return false;
            vis[v]=true;
            ret = check(v, id, cur+1);
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    int u, v;
    for(int i=0; i<m; i++){
        cin>>u>>v;
        node[u].push_back(v);
        node[v].push_back(u);
    }
    bool ans=true;
    for(int i=1; i<=n && ans; i++){
        if(!vis[i]){
            vis[i]=1;
            mark[i]=i;
            ans = check(i, i, 0);
        }
    }
    cout << (ans?"YES":"NO") << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150006;

vector<int> node[maxn];
int vis[maxn];

bool check(int u, int id, int cur){
    if(cur>node[u].size()) return false;
    cout << cur << endl;
    bool ret = true;
    for(int i=0; i<node[u].size() && ret; i++){
        int v = node[u][i];
        if(!vis[v]){
            cout << u << " " << v << " " << cur << " " << vis[v] << endl;
            if(!cur) vis[v]=id;
            if(node[u].size()!=node[v].size()) return false;
            ret = check(v, id, cur+1);
        }else if(vis[u]!=vis[v]){
            return false;
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    int u, v;
    for(int i=0; i<m; i++){
        cin>>u>>v;
        node[u].push_back(v);
        node[v].push_back(u);
    }
    bool ans=true;
    for(int i=0; i<n && ans; i++){
        if(!vis[i]){
            vis[i]=1;
            ans = check(i, 1, 0);
        }
    }
    cout << (ans?"YES":"NO") << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150006;

vector<int> node[maxn];
int mark[maxn];
bool vis[maxn];
bool check(int u, int id, int cur){
    if(cur>node[u].size()) return false;
//    cout << cur << endl;
    bool ret = true;
    if(cur==0){
        for(int i=0; i<node[u].size(); i++){
            int v = node[u][i];
            if(mark[v] && mark[v]!=id) return false;
            mark[v]=id;
        }
    }
    for(int i=0; i<node[u].size() && ret; i++){
        int v = node[u][i];
        if(mark[u]!=mark[v]) return false;
        if(!vis[v]){
            if(node[u].size()!=node[v].size()) return false;
            vis[v]=true;
            ret = check(v, id, cur+1);
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    int n, m;
    cin>>n>>m;
    int u, v;
    for(int i=0; i<m; i++){
        cin>>u>>v;
        node[u].push_back(v);
        node[v].push_back(u);
    }
    bool ans=true;
    for(int i=1; i<=n && ans; i++){
        if(!vis[i]){
            vis[i]=1;
            mark[i]=i;
            ans = check(i, 1, 0);
        }
    }
    cout << (ans?"YES":"NO") << endl;
    return 0;
}


#include<cstdio>
#include<map>
using namespace std;
typedef pair<int,int> Pair;

map<int,Pair> tree;
map<Pair,bool> checks;
int n, m;

void source() {
	Pair u, v;
	for(int i=0; i<m-1; i++) {
		for(int j=i+1; j<m; j++) {
			u = tree[i];
			v = tree[j];
			if(u.first == v.second && (!checks.count(make_pair(u.second,v.first)) && !checks.count(make_pair(v.first,u.second)))) {
				printf("NO\n");
				return;
			}
			else if(u.second == v.first && (!checks.count(make_pair(u.first,v.second)) && !checks.count(make_pair(v.second,u.first) ))) {
				printf("NO\n");
				return;
			}
			else if(u.first == v.first && (!checks.count(make_pair(u.second,v.second)) && !checks.count(make_pair(v.second,u.second)))) {
				printf("NO\n");
				return ;
			}
			else if(u.second == v.second && (!checks.count(make_pair(u.first,v.first)) && !checks.count(make_pair(v.first,u.first)))) {
				printf("NO\n");
				return;
			}
		}
	}
	printf("YES\n");
}

int main()
{
	while(scanf("%d%d", &n, &m) != EOF) {
		tree.clear();
		checks.clear();
		for(int i=0; i<m; i++) {
			int x, y;
			scanf("%d%d", &x, &y);
			tree[i] = make_pair(x,y);
			checks[tree[i]] = true;
		}
		source();
	}
	return 0;
}


#include<cstdio>
#include<map>
using namespace std;
typedef pair<int,int> Pair;

map<int,Pair> tree;
map<Pair,bool> checks;
int n, m;

void source() {
	Pair u, v;
	for(int i=0; i<m-1; i++) {
		for(int j=i+1; j<m; j++) {
			u = tree[i];
			v = tree[j];
			if(u.first == v.second && !checks.count(make_pair(u.second,v.first))) {
				printf("NO\n");
				return;
			}
			else if(u.second == v.first && !checks.count(make_pair(u.first,v.second))) {
				printf("NO\n");
				return;
			}
		}
	}
	printf("YES\n");
}

int main()
{
	while(scanf("%d%d", &n, &m) != EOF) {
		tree.clear();
		checks.clear();
		for(int i=0; i<m; i++) {
			int x, y;
			scanf("%d%d", &x, &y);
			tree[i] = make_pair(x,y);
			checks[tree[i]] = 1;
		}
		source();
	}
	return 0;
}


#include<cstdio>
#include<iostream>
#define maxn 150123
typedef long long ll;

int f[maxn];
ll e[maxn], v[maxn];

int F(int x) {
	if(x==f[x]) return x;
	return f[x] = F(f[x]);
}

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m) != EOF) {
		for(int i=1; i<=n; i++) {
			f[i] = i;
			e[i] = 0;
			v[i] = 1;
		}
		for(int i=1; i<=m; i++) {
			int x, y;
			scanf("%d%d", &x, &y);
			if(F(x)==F(y)) e[f[x]]++;
			else {
				e[f[y]] += e[f[x]] + 1;
				v[f[y]] += v[f[x]];
				f[f[x]] = f[y];
			}
		}
		bool flag = true;
		for(int i=1; i<=n; i++) {
			if(f[i]==i) {
				if(e[i] != v[i]*(v[i]-1)/2) {
					flag = false;
					break;
				}
			}
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}