import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStreamReader;
import java.util.AbstractSequentialList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        static LinkedList<Integer>[] adj;
        static int countv;
        static int counte;
        static boolean[] visited;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            adj = new LinkedList[n + 1];
            for (int i = 1; i <= n; i++)
                adj[i] = new LinkedList<>();
            while (m-- > 0) {
                int a = in.nextInt();
                int b = in.nextInt();
                adj[a].add(b);
                adj[b].add(a);
            }
            visited = new boolean[n + 1];
            boolean possible = true;
            for (int i = 1; i <= n; i++) {
                if (!visited[i]) {
                    countv = 0;
                    counte = 0;
                    DFS(i);
                    if (counte != (long) countv * (long) (countv - 1))
                        possible = false;
                }
            }
            out.println(possible ? "YES" : "NO");
        }

        static void DFS(int source) {
            visited[source] = true;
            countv++;
            counte += adj[source].size();
            Iterator<Integer> iterator = adj[source].iterator();
            while (iterator.hasNext()) {
                int temp = iterator.next();
                if (!visited[temp])
                    DFS(temp);
            }
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            HashSet<Integer>[] adj = new HashSet[n + 1];
            for (int i = 1; i <= n; i++)
                adj[i] = new HashSet<>();
            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                adj[a].add(b);
                adj[b].add(a);
            }
            boolean possible = true;
            for (int i = 1; i <= n; i++) {
                Iterator<Integer> iterator = adj[i].iterator();
                while (iterator.hasNext()) {
                    int temp = iterator.next();
                    Iterator<Integer> second = adj[temp].iterator();
                    while (second.hasNext()) {
                        int tempo = second.next();
                        if (!adj[i].contains(tempo) && tempo != i) {
                            possible = false;
                            //out.println(i+" "+temp+" "+tempo);
                            break;
                        }
                    }
                    if (!possible)
                        break;
                }
                if (!possible)
                    break;
            }
            out.println(possible ? "YES" : "NO");
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.AbstractSequentialList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            LinkedList[] adj = new LinkedList[n + 1];
            for (int i = 1; i <= n; i++)
                adj[i] = new LinkedList();
            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                adj[a].add(b);
                adj[b].add(a);
            }
            boolean possible = true;
            boolean[] visited = new boolean[n + 1];
            for (int i = 1; i <= n; i++) {
                if (!visited[i]) {
                    int countv = 1;
                    int counte = adj[i].size();
                    visited[i] = true;
                    LinkedList<Integer> queue = new LinkedList<>();
                    queue.add(i);
                    while (queue.size() != 0) {
                        int tempo = queue.removeFirst();
                        Iterator<Integer> iterator = adj[tempo].iterator();
                        while (iterator.hasNext()) {
                            int temp = iterator.next();
                            if (!visited[temp]) {
                                visited[temp] = true;
                                countv++;
                                counte += adj[temp].size();
                                queue.add(temp);
                            }
                        }
                    }
                    if (countv > 2) {
                        long check = (long) countv * (long) (countv - 1);
                        if (counte != check) {
                            possible = false;
                            break;
                        }
                    }
                }
            }
            out.println(possible ? "YES" : "NO");
        }

    }
}


import java.util.*;
import java.math.*;
import java.io.*;
public class Test{
	static LinkedList<Integer> adj[];
	static int counte;
	static int countv;
	static boolean[] visited;
	public static void main(String[] args){
		InputStream inp = System.in;
		Scanner in = new Scanner(inp);
		OutputStream outp = System.out;
		PrintWriter out = new PrintWriter(outp);
		int  n = in.nextInt();
		int m = in.nextInt();
		adj = new LinkedList[n+1];
		for(int i=0;i<=n;i++)
			adj[i] = new LinkedList();
		for(int i=0;i<m;i++){
			int a = in.nextInt();
			int b = in.nextInt();
			adj[a].add(b);
			adj[b].add(a);
		}
		boolean possible = true;
		visited = new boolean[n+1];
		for(int i=1;i<=n;i++){
			if(!visited[i]){
				countv = 0;
				counte = 0;
				DFS(i);
				if(countv>2){
					if(counte!=(countv*(countv-1))){
						possible =false;
						break;
					}
				}
			}
		}
		out.println(possible ? "YES" : "NO");
		out.close();
	}

	static void DFS(int source){
		countv++;
		visited[source] = true;
		counte+=adj[source].size();
		Iterator<Integer> iterator = adj[source].iterator();
		while(iterator.hasNext()){
			int temp = iterator.next();
			if(!visited[temp])
				DFS(temp);
		}
	}
}


import java.util.*;
import java.math.*;
import java.io.*;
public class Test{
	static LinkedList<Integer> adj[];
	static int counte;
	static int countv;
	static boolean[] visited;
	public static void main(String[] args){
		FastReader in = new FastReader();
		OutputStream outp = System.out;
		PrintWriter out = new PrintWriter(outp);
		int  n = in.nextInt();
		int m = in.nextInt();
		adj = new LinkedList[n+1];
		for(int i=0;i<=n;i++)
			adj[i] = new LinkedList();
		for(int i=0;i<m;i++){
			int a = in.nextInt();
			int b = in.nextInt();
			adj[a].add(b);
			adj[b].add(a);
		}
		boolean possible = true;
		visited = new boolean[n+1];
		for(int i=1;i<=n;i++){
			if(!visited[i]){
				countv = 0;
				counte = 0;
				DFS(i);
				if(counte!=(countv*(countv-1))){
					possible =false;
					break;
				}
			}
		}
		out.println(possible ? "YES" : "NO");
		out.close();
	}

	static void DFS(int source){
		countv++;
		visited[source] = true;
		Iterator<Integer> iterator = adj[source].iterator();
		while(iterator.hasNext()){
			counte++;
			int temp = iterator.next();
			if(!visited[temp])
				DFS(temp);
		}
	}
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
public class Point {
    private static List<Integer> []Gr;
    private static boolean B[],b;
private static Scanner in = new Scanner (System .in);
private static int n,g,l,k,c;
    public static void main(String[] args) {n=in.nextInt();g=in.nextInt();Gr=new List[n];B=new boolean[n];
        for(int i =0;i<n;i++){Gr[i]=new ArrayList();}
        for(int i =0;i<g;i++){l=in.nextInt();k=in.nextInt();Gr[l-1].add(k-1);Gr[k-1].add(l-1);}
        for(int i =0;i<n;i++){c=0;l=0;l=Gr[i].size();if(!B[i]){Dfs(i);if(l+1!=c){b=true;}}}
        if(b) System.out.println("NO");else System.out.println("YES");
    }
    static void Dfs(int o)
    {B[o]=true;c++;
    for(int i:Gr[o])
    {if(!B[i]){Dfs(i);}}
    if (l!=Gr[o].size()){b=true;}
    }

}


import java.util.*;
public class Point {
    private static List<Integer> []Gr;
    private static boolean B[],b;
private static Scanner in = new Scanner (System .in);
private static int n,g,l,k;
    public static void main(String[] args) {n=in.nextInt();g=in.nextInt();Gr=new List[n];B=new boolean[n];
        for(int i =0;i<n;i++){Gr[i]=new ArrayList();}
        for(int i =0;i<g;i++){l=in.nextInt();k=in.nextInt();Gr[l-1].add(k-1);Gr[k-1].add(l-1);}
        for(int i =0;i<n;i++){l=Gr[i].size();if(!B[i]){Dfs(i);}}
        if(b) System.out.println("NO");else System.out.println("YES");
    }
    static void Dfs(int o)
    {B[o]=true;
    for(int i:Gr[o])
    {if(!B[i]){Dfs(i);}}
    if (l!=Gr[o].size()){b=true;}
    }

}


import java.io.*;
import java.util.*;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author wannabe
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {

            int n = in.nextInt();
            int m = in.nextInt();
            HashSet<Integer>[] adj = new HashSet[n + 1];
            for (int i = 1; i < n + 1; i++) {
                adj[i] = new HashSet<>();
            }

            Set<Integer> visitedNodes = new HashSet<>();

            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                int b = in.nextInt();

                adj[a].addAll(Arrays.asList(a, b));
                adj[b].addAll(Arrays.asList(a, b));
            }

            for (int node = 1; node <= n; node++) {
                if (visitedNodes.contains(node)) continue;
                for (int child : adj[node]) {
                    if (!adj[node].equals(adj[child])) {
                        out.print("NO");
                        return;
                    }
                    visitedNodes.add(child);
                }
                visitedNodes.add(node);
            }

            out.print("YES");
        }

    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        boolean ready() throws IOException {
            return br.ready();
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return str;
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.HashMap;
import java.util.Collections;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author wannabe
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        private Map<Integer, Set<Integer>> adj = new HashMap<>();

        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int m = in.nextInt();

            Set<Integer> nodes = new HashSet<>();
            Set<Integer> visitedNodes = new HashSet<>();

            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                adj.computeIfAbsent(a, key -> new HashSet<>()).addAll(Arrays.asList(a, b));
                adj.computeIfAbsent(b, key -> new HashSet<>()).addAll(Arrays.asList(a, b));
                nodes.add(a);
                nodes.add(b);
            }

            for (int node : nodes) {
                if (visitedNodes.contains(node)) continue;
                for (int child : adj.getOrDefault(node, Collections.emptySet())) {
                    if (!adj.get(node).equals(adj.get(child))) {
                        out.print("NO");
                        return;
                    }
                    visitedNodes.add(child);
                }
                visitedNodes.add(node);
            }

            out.print("YES");
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.AbstractCollection;
import java.util.Arrays;
import java.util.AbstractSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author wannabe
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int m = in.nextInt();
            HashSet<Integer>[] adj = new HashSet[n + 1];
            for (int i = 1; i < n + 1; i++) {
                adj[i] = new HashSet<>();
            }

            Set<Integer> visitedNodes = new HashSet<>();

            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                int b = in.nextInt();

                adj[a].addAll(Arrays.asList(a, b));
                adj[b].addAll(Arrays.asList(a, b));
            }

            for (int node = 1; node <= n; node++) {
                if (visitedNodes.contains(node)) continue;
                for (int child : adj[node]) {
                    if (!adj[node].equals(adj[child])) {
                        out.print("NO");
                        return;
                    }
                    visitedNodes.add(child);
                }
                visitedNodes.add(node);
            }

            out.print("YES");
        }

    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class CF791B
{    //*****************************************    VARIABLE DECLERATION SECTION   ********************************************************************;
         //Integer ArrayList Math TreeMap TreeSet
         // System.out.println
         static  ArrayList<ArrayList<Integer>> graph;
         static ArrayList<Integer>  used;
         static boolean[] visited;
         static int n,m;

    //*****************************************    VARIABLE DECLERATION ENDS   ********************************************************************;

    //************************************************   MAIN FUNCTION  *************************************************************************;
    public static void main(String[] args)
    {
         FastReader scan=new FastReader();
         n=scan.nextInt();m=scan.nextInt();

          graph=new ArrayList<ArrayList<Integer>>();
          visited=new boolean[n+1];

         for(int i=0;i<=n;i++)
         {
            graph.add(new ArrayList<Integer>());
        }
        boolean flag=true;
        while(m--!=0)
        {
            int a=scan.nextInt(),b=scan.nextInt();
            graph.get(a).add(b);
            graph.get(b).add(a);
        }
        for(int i=1;i<=n;)
        {   used=new ArrayList<Integer>();
            while(i<=n&&visited[i]==true)i++;
            if(i<=n)
            dfs(i);
            //System.out.println(used);
            long res=0;
            for(int k=0;k<used.size();k++)
            {     res+=graph.get(used.get(k)).size();
            }
            long ff=used.size();
            ff=ff*(ff-1)/2;
            if(ff!=res/2)
            {
                flag=false;
                break;
            }
        }
        if(flag)
            System.out.println("YES");
        else
            System.out.println("NO");

    }
    //***********************************************  MAIN FUNCTION ENDS   *********************************************************************;

    //**********************************************   AUXILIARY FUNCTIONS  **********************************************************************;
    static void dfs(int i)
    {
        if(!visited[i])
        {
        visited[i]=true;
         used.add(i);
         //System.out.println(used);
        // System.out.println(i+"****************");
        ArrayList<Integer> al=graph.get(i);
        //System.out.println("gebsfkbskj");
       // System.out.println(al);
        for(int j=0;j<al.size();j++){

            dfs(al.get(j));
        }
        }

    }
    //**********************************************   AUXILIARY FUNCTIONS  ENDS  **********************************************************************;

    //**********************************************   INPUT FUNCTIONS     ******************************************************************************;
       static class FastReader
    {   BufferedReader br;   StringTokenizer st;
        public FastReader()
        {  br = new BufferedReader(new  InputStreamReader(System.in)); }
        String next()
        {    while (st == null || !st.hasMoreElements())
            {    try
                {  st = new StringTokenizer(br.readLine()); }
                catch (IOException  e)
                {  e.printStackTrace(); }
            }
            return st.nextToken();
        }
        int nextInt()
        {   return Integer.parseInt(next()); }
        long nextLong()
        {   return Long.parseLong(next()); }
        double nextDouble()
        {  return Double.parseDouble(next()); }
        String nextLine()
        { String str = "";
            try
            {     str = br.readLine(); }
            catch (IOException e)
            {     e.printStackTrace(); }
            return str;
        }
    }
    //**********************************************   INPUT FUNCTIONS     ******************************************************************************;
}


import java.io.*;
import java.lang.Math.*;
import java.util.*;

public final class BearAndFriendship{

	public static void main(String args[]) throws Exception{

		int a[] = Br.getIntA(2);
		int N = a[0];
		int M = a[1];

		ArrayList<Integer> list[] = new ArrayList[N];
		boolean done[] = new boolean[N];
		for(int n=0; n<N; n++){
			list[n] = new ArrayList<>();
			done[n] = false;
		}

		for(int m=0; m<M; m++){
			a = Br.getIntA(2);
			list[a[0]-1].add(a[1]-1);
			list[a[1]-1].add(a[0]-1);
		}

		if(check(list, done, N))
			println("YES");
		else
			println("NO");

	}

	static boolean check(ArrayList<Integer> list[], boolean done[], int N){
		int cur = 0;
		while(cur < N){
			if(!done[cur]){
				done[cur] = true;
				HashSet<Integer> set = new HashSet<>();
				int size = list[cur].size();
				set.add(cur);
				// println("checking " + cur);
				for(int i=0; i<size; i++){
					int ele = list[cur].get(i);
					set.add(ele);
					done[ele] = true;
				}
				for(int i=0; i<size; i++){
					int ele = list[cur].get(i);
					int size2 = list[ele].size();
					// println("    checking " + ele);
					int num = 1;
					for(int j=0; j<size2; j++){
						// println("        checking " + list[ele].get(j));
						if(!set.contains(list[ele].get(j)))
							return false;
						else
							num++;

					}
					if(set.size() != num)
						return false;

				}
			}
			cur++;
		}

		return true;
	}

	// class for Reader
	static class Br {

		final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		static int getInt() throws IOException{
			return Integer.parseInt(br.readLine());
		}

		static long getLong() throws IOException{
			return Long.parseLong(br.readLine());
		}

		static double getDouble() throws IOException{
			return Double.parseDouble(br.readLine());
		}

		static int[] getIntA() throws IOException{
			String temp[] = br.readLine().split(" ");
			int l = temp.length;

			int a[] = new int[l];

			for(int i=0; i<l; i++){
				a[i] = Integer.parseInt(temp[i]);
			}

			return a;
		}

		static int[] getIntA(int l) throws IOException{
			String temp[] = br.readLine().split(" ");
			int a[] = new int[l];

			for(int i=0; i<l; i++){
				a[i] = Integer.parseInt(temp[i]);
			}

			return a;
		}

		static long[] getLongA(int l) throws IOException{
			String temp[] = br.readLine().split(" ");
			long a[] = new long[l];

			for(int i=0; i<l; i++){
				a[i] = Long.parseLong(temp[i]);
			}

			return a;
		}

		static String getString() throws IOException{
			return br.readLine();
		}

	}

	// class for MaTh libraries
	static class Mt{
		static double precision = 0.00001;

		static double sqrt(double a){
			return newton_raphson(a, a/2);
		}

		static double newton_raphson(double a, double guess){
			if(guess*guess - a <= precision)
				return guess;

			guess = guess - (guess * guess - a)/ (2 * guess);
			return newton_raphson(a, guess);
		}

		static long modPow(long a, long x, long p){

			long ans = 1;
			while(x > 0){
				if(x %2 !=0){
					ans = (ans*a)%p;
				}
				a = (a*a)%p;
				x/=2;
			}

			return (ans%p);
		}
	}

	static<T> void print(T s){
		System.out.print(s);
	}

	static<T> void println(T s){
		System.out.println(s);
	}
}


import java.io.*;
import java.lang.Math.*;
import java.util.*;

public final class BearAndFriendship{

	public static void main(String args[]) throws Exception{

		int a[] = Br.getIntA(2);
		int N = a[0];
		int M = a[1];

		ArrayList<Integer> list[] = new ArrayList[N];
		boolean done[] = new boolean[N];
		for(int n=0; n<N; n++){
			list[n] = new ArrayList<>();
			done[n] = false;
		}

		for(int m=0; m<M; m++){
			a = Br.getIntA(2);
			list[a[0]-1].add(a[1]-1);
			list[a[1]-1].add(a[0]-1);
		}

		if(check(list, done, N))
			println("YES");
		else
			println("NO");

	}

	static boolean check(ArrayList<Integer> list[], boolean done[], int N){
		int cur = 0;
		while(cur < N){
			if(!done[cur]){
				done[cur] = true;
				HashSet<Integer> set = new HashSet<>();
				int size = list[cur].size();
				set.add(cur);
				// println("checking " + cur);
				for(int i=0; i<size; i++){
					int ele = list[cur].get(i);
					set.add(ele);
					done[ele] = true;
				}
				for(int i=0; i<size; i++){
					int ele = list[cur].get(i);
					int size2 = list[ele].size();
					// println("    checking " + ele);
					for(int j=0; j<size2; j++){
						// println("        checking " + list[ele].get(j));
						if(!set.contains(list[ele].get(j)))
							return false;
					}
				}
			}
			cur++;
		}

		return true;
	}

	// class for Reader
	static class Br {

		final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		static int getInt() throws IOException{
			return Integer.parseInt(br.readLine());
		}

		static long getLong() throws IOException{
			return Long.parseLong(br.readLine());
		}

		static double getDouble() throws IOException{
			return Double.parseDouble(br.readLine());
		}

		static int[] getIntA() throws IOException{
			String temp[] = br.readLine().split(" ");
			int l = temp.length;

			int a[] = new int[l];

			for(int i=0; i<l; i++){
				a[i] = Integer.parseInt(temp[i]);
			}

			return a;
		}

		static int[] getIntA(int l) throws IOException{
			String temp[] = br.readLine().split(" ");
			int a[] = new int[l];

			for(int i=0; i<l; i++){
				a[i] = Integer.parseInt(temp[i]);
			}

			return a;
		}

		static long[] getLongA(int l) throws IOException{
			String temp[] = br.readLine().split(" ");
			long a[] = new long[l];

			for(int i=0; i<l; i++){
				a[i] = Long.parseLong(temp[i]);
			}

			return a;
		}

		static String getString() throws IOException{
			return br.readLine();
		}

	}

	// class for MaTh libraries
	static class Mt{
		static double precision = 0.00001;

		static double sqrt(double a){
			return newton_raphson(a, a/2);
		}

		static double newton_raphson(double a, double guess){
			if(guess*guess - a <= precision)
				return guess;

			guess = guess - (guess * guess - a)/ (2 * guess);
			return newton_raphson(a, guess);
		}

		static long modPow(long a, long x, long p){

			long ans = 1;
			while(x > 0){
				if(x %2 !=0){
					ans = (ans*a)%p;
				}
				a = (a*a)%p;
				x/=2;
			}

			return (ans%p);
		}
	}

	static<T> void print(T s){
		System.out.print(s);
	}

	static<T> void println(T s){
		System.out.println(s);
	}
}


import java.io.*;
import java.lang.Math.*;
import java.util.*;

public final class BearAndFriendship{

	public static void main(String args[]) throws Exception{

		int a[] = Br.getIntA(2);
		int N = a[0];
		int M = a[1];

		ArrayList<Integer> list[] = new ArrayList[N];
		boolean done[] = new boolean[N];
		for(int n=0; n<N; n++){
			list[n] = new ArrayList<>();
			done[n] = false;
		}

		for(int m=0; m<M; m++){
			a = Br.getIntA(2);
			list[a[0]-1].add(a[1]-1);
			list[a[1]-1].add(a[0]-1);
		}

		if(check(list, done, N))
			println("YES");
		else
			println("NO");

	}

	static boolean check(ArrayList<Integer> list[], boolean done[], int N){
		int cur = 0;
		while(cur < N){
			if(!done[cur]){
				done[cur] = true;
				HashSet<Integer> set = new HashSet<>();
				int size = list[cur].size();
				set.add(cur);
				// println("checking " + cur);
				for(int i=0; i<size; i++){
					int ele = list[cur].get(i);
					set.add(ele);
					// done[ele] = true;
				}
				for(int i=0; i<size; i++){
					int ele = list[cur].get(i);
					int size2 = list[ele].size();
					// println("    checking " + ele);
					int num = 1;
					for(int j=0; j<size2; j++){
						// println("        checking " + list[ele].get(j));
						if(!set.contains(list[ele].get(j)))
							return false;
						// else
						// 	num++;

					}
					// if(set.size() != num)
					// 	return false;

				}
			}
			cur++;
		}

		return true;
	}

	// class for Reader
	static class Br {

		final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		static int getInt() throws IOException{
			return Integer.parseInt(br.readLine());
		}

		static long getLong() throws IOException{
			return Long.parseLong(br.readLine());
		}

		static double getDouble() throws IOException{
			return Double.parseDouble(br.readLine());
		}

		static int[] getIntA() throws IOException{
			String temp[] = br.readLine().split(" ");
			int l = temp.length;

			int a[] = new int[l];

			for(int i=0; i<l; i++){
				a[i] = Integer.parseInt(temp[i]);
			}

			return a;
		}

		static int[] getIntA(int l) throws IOException{
			String temp[] = br.readLine().split(" ");
			int a[] = new int[l];

			for(int i=0; i<l; i++){
				a[i] = Integer.parseInt(temp[i]);
			}

			return a;
		}

		static long[] getLongA(int l) throws IOException{
			String temp[] = br.readLine().split(" ");
			long a[] = new long[l];

			for(int i=0; i<l; i++){
				a[i] = Long.parseLong(temp[i]);
			}

			return a;
		}

		static String getString() throws IOException{
			return br.readLine();
		}

	}

	// class for MaTh libraries
	static class Mt{
		static double precision = 0.00001;

		static double sqrt(double a){
			return newton_raphson(a, a/2);
		}

		static double newton_raphson(double a, double guess){
			if(guess*guess - a <= precision)
				return guess;

			guess = guess - (guess * guess - a)/ (2 * guess);
			return newton_raphson(a, guess);
		}

		static long modPow(long a, long x, long p){

			long ans = 1;
			while(x > 0){
				if(x %2 !=0){
					ans = (ans*a)%p;
				}
				a = (a*a)%p;
				x/=2;
			}

			return (ans%p);
		}
	}

	static<T> void print(T s){
		System.out.print(s);
	}

	static<T> void println(T s){
		System.out.println(s);
	}
}


import java.io.*;
	    import java.math.*;
	    import java.util.*;
	    import javax.print.attribute.SetOfIntegerSyntax;

	    public class Main  {
	    	private static InputStream stream;
	    	private static byte[] buf = new byte[1024];
	    	private static int curChar;
	    	private static int numChars;
	    	private static SpaceCharFilter filter;
	    	private static PrintWriter pw;
	    	private static long count = 0,mod=1000000007;
	    	private static TreeSet<Integer>ts[]=new TreeSet[200000];
	    	private static HashSet hs=new HashSet();

	    	/*public class Pair implements Comparable<Pair> {
		    	final Integer cost;
		        final Integer index;
		        public
		        Pair(int c,int i){
		        	cost=(Integer)c;
		        	index=(Integer)i;
		        }
		        @Override
		        public int compareTo(Pair p) {
		            return this.cost.compareTo(p.cost);
		            ///return result;
		            //return (result == 0) ? e.compareTo(pair.e) : result;
		        }
		    }*/
	    	 public static void main(String[] args) {
		        	InputReader(System.in);
		    		pw = new PrintWriter(System.out);
		            new Thread(null ,new Runnable(){
		               public void run(){
		                   try{
		                       soln();
		                       pw.close();
		                   } catch(Exception e){
		                       e.printStackTrace();
		                   }
		               }
		           },"1",1<<26).start();
		       }

	    	public static long gcd(long x, long y) {
	    		if (x == 0)
	    			return y;
	    		else
	    			return gcd( y % x,x);
	    	}

	    	private static int BinarySearch(int a[], int low, int high, int target) {
	    		if (low > high)
	    			return -1;
	    		int mid = low + (high - low) / 2;
	    		if (a[mid] == target)
	    			return mid;
	    		if (a[mid] > target)
	    			high = mid - 1;
	    		if (a[mid] < target)
	    			low = mid + 1;
	    		return BinarySearch(a, low, high, target);
	    	}

	    	public static String reverseString(String s) {
	    		StringBuilder sb = new StringBuilder(s);
	    		sb.reverse();
	    		return (sb.toString());
	    	}

	    	public static long pow(long n, long p) {
	    		if(p==0)
	    			return 1;
	    		if(p==1)
	    			return n%mod;
	    		if(p%2==0){
	    			long temp=pow(n, p/2);
	    		return (temp*temp)%mod;
	    		}else{
	    			 	long temp=pow(n,p/2);
	    			 	temp=(temp*temp)%mod;
	    			 	return(temp*n)%mod;

	    		}
	    	}

	    	public static int[] radixSort(int[] f) {
	    		int[] to = new int[f.length];
	    		{
	    			int[] b = new int[65537];
	    			for (int i = 0; i < f.length; i++)
	    				b[1 + (f[i] & 0xffff)]++;
	    			for (int i = 1; i <= 65536; i++)
	    				b[i] += b[i - 1];
	    			for (int i = 0; i < f.length; i++)
	    				to[b[f[i] & 0xffff]++] = f[i];
	    			int[] d = f;
	    			f = to;
	    			to = d;
	    		}
	    		{
	    			int[] b = new int[65537];
	    			for (int i = 0; i < f.length; i++)
	    				b[1 + (f[i] >>> 16)]++;
	    			for (int i = 1; i <= 65536; i++)
	    				b[i] += b[i - 1];
	    			for (int i = 0; i < f.length; i++)
	    				to[b[f[i] >>> 16]++] = f[i];
	    			int[] d = f;
	    			f = to;
	    			to = d;
	    		}
	    		return f;
	    	}

	    	public static int nextPowerOf2(final int a) {
	    		int b = 1;
	    		while (b < a) {
	    			b = b << 1;
	    		}
	    		return b;
	    	}

	    	public static boolean PointInTriangle(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) {
	    		int s = p2 * p5 - p1 * p6 + (p6 - p2) * p7 + (p1 - p5) * p8;
	    		int t = p1 * p4 - p2 * p3 + (p2 - p4) * p7 + (p3 - p1) * p8;

	    		if ((s < 0) != (t < 0))
	    			return false;

	    		int A = -p4 * p5 + p2 * (p5 - p3) + p1 * (p4 - p6) + p3 * p6;
	    		if (A < 0.0) {
	    			s = -s;
	    			t = -t;
	    			A = -A;
	    		}
	    		return s > 0 && t > 0 && (s + t) <= A;
	    	}

	    	public static float area(int x1, int y1, int x2, int y2, int x3, int y3) {
	    		return (float) Math.abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
	    	}

	    	public static boolean isPrime(int n) {
	    		// Corner cases
	    		if (n <= 1)
	    			return false;
	    		if (n <= 3)
	    			return true;

	    		// This is checked so that we can skip
	    		// middle five numbers in below loop
	    		if (n % 2 == 0 || n % 3 == 0)
	    			return false;

	    		for (int i = 5; i * i <= n; i = i + 6)
	    			if (n % i == 0 || n % (i + 2) == 0)
	    				return false;

	    		return true;
	    	}

	    	//merge Sort

	    	static long sort(int a[])
	    	{  int n=a.length;
	    		int b[]=new int[n];
	    		return mergeSort(a,b,0,n-1);}
	    	static long mergeSort(int a[],int b[],long left,long right)
	    	{ long c=0;if(left<right)
	    	 {   long mid=left+(right-left)/2;
	    		 c= mergeSort(a,b,left,mid);
	    		 c+=mergeSort(a,b,mid+1,right);
	    		 c+=merge(a,b,left,mid+1,right); }
	    		return c;	 }
	    	static long merge(int a[],int  b[],long left,long mid,long right)
	    	{long c=0;int i=(int)left;int j=(int)mid; int k=(int)left;
	    	while(i<=(int)mid-1&&j<=(int)right)
	    	{ if(a[i]>a[j]) {b[k++]=a[i++]; }
	    	else	{ b[k++]=a[j++];c+=mid-i;}}
	    	while (i <= (int)mid - 1)   b[k++] = a[i++];
	    	while (j <= (int)right) b[k++] = a[j++];
	    	for (i=(int)left; i <= (int)right; i++)
	    		a[i] = b[i];  return c;  }
	    	public static boolean isSubSequence(String large, String small, int largeLen, int smallLen) {
	    		//base cases
	    		if (largeLen == 0)
	    			return false;
	    		if (smallLen == 0)
	    			return true;
	    		// If last characters of two strings are matching
	    		if (large.charAt(largeLen - 1) == small.charAt(smallLen - 1))
	    			isSubSequence(large, small, largeLen - 1, smallLen - 1);
	    		// If last characters are not matching
	    		return isSubSequence(large, small, largeLen - 1, smallLen);
	    	}

	    	// To Get Input
	    	// Some Buffer Methods

	    	public static void InputReader(InputStream stream1) {
	    		stream = stream1;
	    	}

	    	private static boolean isWhitespace(int c) {
	    		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    	}

	    	private static boolean isEndOfLine(int c) {
	    		return c == '\n' || c == '\r' || c == -1;
	    	}

	    	private static int read() {
	    		if (numChars == -1)
	    			throw new InputMismatchException();
	    		if (curChar >= numChars) {
	    			curChar = 0;
	    			try {
	    				numChars = stream.read(buf);
	    			} catch (IOException e) {
	    				throw new InputMismatchException();
	    			}
	    			if (numChars <= 0)
	    				return -1;
	    		}
	    		return buf[curChar++];
	    	}

	    	private static int nextInt() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		int sgn = 1;
	    		if (c == '-') {
	    			sgn = -1;
	    			c = read();
	    		}
	    		int res = 0;
	    		do {
	    			if (c < '0' || c > '9')
	    				throw new InputMismatchException();
	    			res *= 10;
	    			res += c - '0';
	    			c = read();
	    		} while (!isSpaceChar(c));
	    		return res * sgn;
	    	}

	    	private static long nextLong() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		int sgn = 1;
	    		if (c == '-') {
	    			sgn = -1;
	    			c = read();
	    		}
	    		long res = 0;
	    		do {
	    			if (c < '0' || c > '9')
	    				throw new InputMismatchException();
	    			res *= 10;
	    			res += c - '0';
	    			c = read();
	    		} while (!isSpaceChar(c));
	    		return res * sgn;
	    	}

	    	private static String nextToken() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		StringBuilder res = new StringBuilder();
	    		do {
	    			res.appendCodePoint(c);
	    			c = read();
	    		} while (!isSpaceChar(c));
	    		return res.toString();
	    	}

	    	private static String nextLine() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		StringBuilder res = new StringBuilder();
	    		do {
	    			res.appendCodePoint(c);
	    			c = read();
	    		} while (!isEndOfLine(c));
	    		return res.toString();
	    	}

	    	private static int[] nextIntArray(int n) {
	    		int[] arr = new int[n];
	    		for (int i = 0; i < n; i++) {
	    			arr[i] = nextInt();
	    		}
	    		return arr;
	    	}

	    	private static int[][] next2dArray(int n, int m) {
	    		int[][] arr = new int[n][m];
	    		for (int i = 0; i < n; i++) {
	    			for (int j = 0; j < m; j++) {
	    				arr[i][j] = nextInt();
	    			}
	    		}
	    		return arr;
	    	}
	    	private static char[][] nextCharArray(int n,int m){
	    		char [][]c=new char[n][m];
	    		for(int i=0;i<n;i++){
	    			String s=nextLine();
	    			for(int j=0;j<s.length();j++){
	    				c[i][j]=s.charAt(j);
	    			}
	    		}
	    		return c;
	    	}

	    	private static long[] nextLongArray(int n) {
	    		long[] arr = new long[n];
	    		for (int i = 0; i < n; i++) {
	    			arr[i] = nextLong();
	    		}
	    		return arr;
	    	}

	    	private static void pArray(int[] arr) {
	    		for (int i = 0; i < arr.length; i++) {
	    			pw.print(arr[i] + " ");
	    		}
	    		pw.println();
	    		return;
	    	}

	    	private static void pArray(long[] arr) {
	    		for (int i = 0; i < arr.length; i++) {
	    			pw.print(arr[i] + " ");
	    		}
	    		pw.println();
	    		return;
	    	}

	    	private static void pArray(boolean[] arr) {
	    		for (int i = 0; i < arr.length; i++) {
	    			pw.print(arr[i] + " ");
	    		}
	    		pw.println();
	    		return;
	    	}

	    	private static boolean isSpaceChar(int c) {
	    		if (filter != null)
	    			return filter.isSpaceChar(c);
	    		return isWhitespace(c);
	    	}

	    	private interface SpaceCharFilter {
	    		public boolean isSpaceChar(int ch);
	    	}

	    	//----------------------------------------My Code------------------------------------------------//
	    	static LinkedList<Integer> adj[];
	    	static boolean visited[];
	    	static int arr[];
	    	static int cou=0;
	    	private static void soln() {
	    		int n=nextInt();
	    		int k=nextInt();
	    		//int m=nextInt();
	    		adj=new LinkedList[n];
	    		arr=new int[n];
	    		for(int i=0;i<n;i++){
	    			adj[i]=new LinkedList<Integer>();
	    		}
	    		visited=new boolean[n];
	    		for(int i=0;i<k;i++){
	    			int u=nextInt()-1;
	    			int w=nextInt()-1;
	    			adj[u].add(w);
	    			adj[w].add(u);
	    		}
	    		for(int i=0;i<n;i++){
	    			if(visited[i]!=true){
	    				cou++;
	    				arr[i]=cou;
	    				dfs(i);
	    			}
	    		}
	    		//pw.println(cou);
	    		/*for(int i=0;i<n;i++){
	    			pw.print(arr[i]+" ");
	    		}*/
	    		//pw.println();
	    		int temp[]=new int[cou];
	    		int i=0;
	    		for( i=0;i<n;i++){
	    			temp[arr[i]-1]++;
	    			/*if(temp[arr[i]-1]!=0){
	    				if(adj[i].size()!=temp[arr[i]-1]){
	    					break;
	    				}
	    			}
	    			else{
	    				temp[arr[i]-1]=;
	    			}*/
	    		}
	    		/*for(i=0;i<cou;i++){
	    			pw.print(temp[i]+" ");
	    		}*/
	    		pw.println();
	    		int p;
	    		for( p=0;p<n;p++){
	    			if(temp[arr[p]-1]!=(adj[p].size()+1)){
	    				break;
	    			}
	    		}
	    		if(p==n){
	    			pw.println("YES");
	    		}
	    		else pw.println("NO");
	    	}
	    	private static void dfs(int i){
	    		visited[i]=true;
	    		for(int j:adj[i]){
	    			if(visited[j]==false){
	    				arr[j]=cou;
	    				dfs(j);
	    			}
	    		}
	    	}

	    		//-----------------------------------------The End--------------------------------------------------------------------------//

	 }

		class Pair implements Comparable<Pair>{

			int ind;
			int cost;

			Pair(int ind,int len){
				this.cost=ind;
				this.ind=len;
			}
			@Override
			public int compareTo(Pair o) {
				// TODO Auto-generated method stub
			//	Sort in increasing order
				//int result= this.cost.compareTo(o.cost);
				return 0;
			}

		}
	        class  Graph{
	        	private static int V,level[][],count=-1,lev_dfs[],degree=0,no_vert_conn_comp=0;
	        	private Stack <Integer>st=new Stack();
	        	private static LinkedList<Integer > adj[];
	        	private boolean[][] Visite;
	        	private static boolean [] Visited;
	        	private static HashSet<Integer> Vis=new HashSet();
	        	private static Stack<Integer> topo_sort=new Stack<>();
	        	private static HashMap<String,Integer> hm=new HashMap<>();

	    Graph(int V){
	    V++;
	    this.V=(V);
	    adj=new LinkedList[V];
	    Visite=new boolean[100][100];

 	    Visited=new boolean[V];
	    level=new int[100][100];
	    lev_dfs=new int[V];
	   for(int i=0;i<V;i++)
		   adj[i]=new LinkedList<Integer>();

	    }
	    void setup(int n,int m){
	    	//HashMap<String,Integer> hm=new HashMap<>();
    		int co=1;
	    	for(int i=0;i<n;i++){
    			for(int j=0;j<m;j++){
    				String s="";
    				s+=(i)+" "+(j);
    				hm.put(s, co);
    			co++;
    			}
    		}
	    }
	   void addEdge(int v,int w){

	    	if(adj[v]==null){
	    		adj[v]=new LinkedList();
	    	}
	    	adj[v].add(w);

	    }

	 public static void top_ans(){
	while(topo_sort.size()!=0)
{
	System.out.print(hm.get(topo_sort.peek()));
topo_sort.pop();
}

	 }
	 public static void topoSort(int startVert){
		 if(!Vis.contains(startVert)){
			 topoSortUtil(startVert);
		 }
	 }
	    public static void topoSortUtil(int curr_Vert){
	    	Vis.add(curr_Vert);
	    	Iterator<Integer> it=adj[curr_Vert].listIterator();

	    	while(it.hasNext()){
	    		int n=it.next();
	   // 		System.out.println(n);
	    		if(!Vis.contains(n)){
	    			topoSortUtil(n);
	    		}

	    	}
	    	topo_sort.push(curr_Vert);
	    }

	    public static int BFS2(int startVert){
	    	Visited=new boolean[V];
	    	for(int i=1;i<V;i++){
	    		lev_dfs[i]=-1;
	    	}
	    //	System.out.println(startVert);
	    	Queue<Integer> q=new LinkedList<Integer>();
	    	q.add(startVert);

	    	lev_dfs[startVert]=0;
	    	while(!q.isEmpty()){
	    		int top=q.poll();

	    		Iterator<Integer> i= adj[top].listIterator();
	    		while(i.hasNext()){
	    			int n=i.next();
	    	//		System.out.println(top+" "+n);
	    			if(!Visited[n]){
	    				q.add(n);
	    				Visited[n]=true;
	    				lev_dfs[n]=lev_dfs[top]+1;

	    			}
	    		}
	    	}

	    //	q.clear();
	    	return -1;
	    }
	    public static int getAn(int end){
	    	return lev_dfs[end];
	    }
	    public int getEd(){
	    	return degree/2;
	    }
	    public void get(int from,int to){
	    	int h=lev_dfs[from]-lev_dfs[to];
	    	if(h<=0){
	    		System.out.println(-1);
	    	}else{
	    		System.out.println(h-1);
	    	}
	    }
	    private static boolean check(int x,int y,char c[][]){

			if((x>=0 && y>=0) && (x<c.length && y<c[0].length) && c[x][y]!='#'){

				return true;
			}
			return false;
		}
	    public int BFS(int x,int y,int k,char[][] c)
	    {
	    	 LinkedList<Pair> queue = new LinkedList<Pair>();
	        //Visited[s]=true;
	   //     queue.add(new Pair(x,y));
	       int count=0;
	   level[x][y]=-1;
	   c[x][y]='M';
	        while (!queue.isEmpty())
	        {
	            Pair temp = queue.poll();

	        }
	        return V;
	    }

	     public long dfs(int startVertex,int end){
	    //	 getAns(startVertex);
	    	 Visited=new boolean[V];
	    	 if(!Visited[startVertex])  {

	   return dfsUtil(startVertex,end);
	    	//return getAns();
	    	}

	    return 0;
	    	}
	 private long dfsUtil(int startVertex,int end) {//0-Blue 1-Pink
		 int c=1;

		 long cout=0;
	      degree=0;
	    	Visited[startVertex]=true;
	    	lev_dfs[startVertex]=0;
	      st.push(startVertex);
	      int temp=-1;

	    while(!st.isEmpty()){

	    	int top=st.pop();
	    temp=Math.max(temp, top);
	    //	ts.add(top);
	    	Iterator<Integer> i=adj[top].listIterator();

	    while(i.hasNext()){
	    //	System.out.println(top);
	    	int n=i.next();
	     if( !Visited[n]){
	    				Visited[n]=true;

	    			//	col_freq[col[n-1]]++;
	    				c++;
	    				st.push(n);
	    					lev_dfs[n]=lev_dfs[top]+1;
	    					if(n==end){
	    	    				return lev_dfs[n];
	    	    				}
	    		 }
	         }
	 }
	 //   System.out.println(temp);
	    if(lev_dfs[temp]+(end-temp)<=0){
	    	return end-startVertex;
	    }
	    return Math.min(end-startVertex, lev_dfs[temp]+(end-temp));

	    }

	        }

	    class Dsu{
	    	private int rank[], parent[] ,n;

	    	Dsu(int size){
	    		this.n=size+1;
	    		rank=new int[n];
	    		parent=new int[n];
	    	makeSet();
	    	}

	    	void makeSet(){
	    		for(int i=0;i<n;i++){
	    			parent[i]=i;
	    		}
	    	}

	    	int find(int x){
	    		if(parent[x]!=x){

	    			parent[x]=find(parent[x]);
	    		}
	    		return parent[x];
	    	}

	    	void union(int x,int y){
	    		int xRoot=find(x);
	    		int yRoot=find(y);

	    		if(xRoot==yRoot)
	    			return;
	    		if(rank[xRoot]<rank[yRoot]){
	    		parent[xRoot]=yRoot;
	    		}else if(rank[yRoot]<rank[xRoot]){
	    			parent[yRoot]=xRoot;
	    		}else{
	    			parent[yRoot]=xRoot;
	    			rank[xRoot]++;
	    		}

	    	}

	    }
	    class Heap{

	    	public static void build_max_heap(long []a,int size){

	    		for(int i=size/2;i>0;i--){
	    			max_heapify(a, i,size);
	    		}

	    			}
	    	private static void max_heapify(long[] a,int i,int size){
	    		int left_child=2*i;
	    		int right_child=(2*i+1);
	    		int largest=0;

	    		if(left_child<size && a[left_child]>a[i]){
	    			largest=left_child;
	    		}else{
	    			largest=i;
	    		}

	    		if(right_child<size && a[right_child]>a[largest]){
	    			largest=right_child;
	    		}
	    		if(largest!=i){
	    			long temp=a[largest];
	    			a[largest]=a[i];
	    			a[i]=temp;
	    			max_heapify(a, largest,size);
	    		}
	    	}
	    	private static void min_heapify(int[] a,int i){
	    		int left_child=2*i;
	    		int right_child=(2*i+1);
	    		int largest=0;

	    		if(left_child<a.length && a[left_child]<a[i]){
	    			largest=left_child;
	    		}else{
	    			largest=i;
	    		}

	    		if(right_child<a.length && a[right_child]<a[largest]){
	    			largest=right_child;
	    		}
	    		if(largest!=i){
	    			int temp=a[largest];
	    			a[largest]=a[i];
	    			a[i]=temp;
	    			min_heapify(a, largest);
	    		}
	    	}
	    	public static void extract_max(int size,long a[]){
	    		if(a.length>1){
	    			long max=a[1];
	    			a[1]=a[a.length-1];
	    			size--;
	    			max_heapify(a, 1,a.length-1);
	    		}
	    	}
	    }

	    class MyComp implements Comparator<Long>{

			@Override
			public int compare(Long o1, Long o2) {
				if(o1<o2){
					return 1;
				}else if(o1>o2){
					return -1;
				}
				return 0;

			}
	    }


import java.io.*;
	    import java.math.*;
	    import java.util.*;
	    import javax.print.attribute.SetOfIntegerSyntax;

	    public class Main  {
	    	private static InputStream stream;
	    	private static byte[] buf = new byte[1024];
	    	private static int curChar;
	    	private static int numChars;
	    	private static SpaceCharFilter filter;
	    	private static PrintWriter pw;
	    	private static long count = 0,mod=1000000007;
	    	private static TreeSet<Integer>ts[]=new TreeSet[200000];
	    	private static HashSet hs=new HashSet();

	    	/*public class Pair implements Comparable<Pair> {
		    	final Integer cost;
		        final Integer index;
		        public
		        Pair(int c,int i){
		        	cost=(Integer)c;
		        	index=(Integer)i;
		        }
		        @Override
		        public int compareTo(Pair p) {
		            return this.cost.compareTo(p.cost);
		            ///return result;
		            //return (result == 0) ? e.compareTo(pair.e) : result;
		        }
		    }*/
	    	 public static void main(String[] args) {
		        	InputReader(System.in);
		    		pw = new PrintWriter(System.out);
		            new Thread(null ,new Runnable(){
		               public void run(){
		                   try{
		                       soln();
		                       pw.close();
		                   } catch(Exception e){
		                       e.printStackTrace();
		                   }
		               }
		           },"1",1<<26).start();
		       }

	    	public static long gcd(long x, long y) {
	    		if (x == 0)
	    			return y;
	    		else
	    			return gcd( y % x,x);
	    	}

	    	private static int BinarySearch(int a[], int low, int high, int target) {
	    		if (low > high)
	    			return -1;
	    		int mid = low + (high - low) / 2;
	    		if (a[mid] == target)
	    			return mid;
	    		if (a[mid] > target)
	    			high = mid - 1;
	    		if (a[mid] < target)
	    			low = mid + 1;
	    		return BinarySearch(a, low, high, target);
	    	}

	    	public static String reverseString(String s) {
	    		StringBuilder sb = new StringBuilder(s);
	    		sb.reverse();
	    		return (sb.toString());
	    	}

	    	public static long pow(long n, long p) {
	    		if(p==0)
	    			return 1;
	    		if(p==1)
	    			return n%mod;
	    		if(p%2==0){
	    			long temp=pow(n, p/2);
	    		return (temp*temp)%mod;
	    		}else{
	    			 	long temp=pow(n,p/2);
	    			 	temp=(temp*temp)%mod;
	    			 	return(temp*n)%mod;

	    		}
	    	}

	    	public static int[] radixSort(int[] f) {
	    		int[] to = new int[f.length];
	    		{
	    			int[] b = new int[65537];
	    			for (int i = 0; i < f.length; i++)
	    				b[1 + (f[i] & 0xffff)]++;
	    			for (int i = 1; i <= 65536; i++)
	    				b[i] += b[i - 1];
	    			for (int i = 0; i < f.length; i++)
	    				to[b[f[i] & 0xffff]++] = f[i];
	    			int[] d = f;
	    			f = to;
	    			to = d;
	    		}
	    		{
	    			int[] b = new int[65537];
	    			for (int i = 0; i < f.length; i++)
	    				b[1 + (f[i] >>> 16)]++;
	    			for (int i = 1; i <= 65536; i++)
	    				b[i] += b[i - 1];
	    			for (int i = 0; i < f.length; i++)
	    				to[b[f[i] >>> 16]++] = f[i];
	    			int[] d = f;
	    			f = to;
	    			to = d;
	    		}
	    		return f;
	    	}

	    	public static int nextPowerOf2(final int a) {
	    		int b = 1;
	    		while (b < a) {
	    			b = b << 1;
	    		}
	    		return b;
	    	}

	    	public static boolean PointInTriangle(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) {
	    		int s = p2 * p5 - p1 * p6 + (p6 - p2) * p7 + (p1 - p5) * p8;
	    		int t = p1 * p4 - p2 * p3 + (p2 - p4) * p7 + (p3 - p1) * p8;

	    		if ((s < 0) != (t < 0))
	    			return false;

	    		int A = -p4 * p5 + p2 * (p5 - p3) + p1 * (p4 - p6) + p3 * p6;
	    		if (A < 0.0) {
	    			s = -s;
	    			t = -t;
	    			A = -A;
	    		}
	    		return s > 0 && t > 0 && (s + t) <= A;
	    	}

	    	public static float area(int x1, int y1, int x2, int y2, int x3, int y3) {
	    		return (float) Math.abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
	    	}

	    	public static boolean isPrime(int n) {
	    		// Corner cases
	    		if (n <= 1)
	    			return false;
	    		if (n <= 3)
	    			return true;

	    		// This is checked so that we can skip
	    		// middle five numbers in below loop
	    		if (n % 2 == 0 || n % 3 == 0)
	    			return false;

	    		for (int i = 5; i * i <= n; i = i + 6)
	    			if (n % i == 0 || n % (i + 2) == 0)
	    				return false;

	    		return true;
	    	}

	    	//merge Sort

	    	static long sort(int a[])
	    	{  int n=a.length;
	    		int b[]=new int[n];
	    		return mergeSort(a,b,0,n-1);}
	    	static long mergeSort(int a[],int b[],long left,long right)
	    	{ long c=0;if(left<right)
	    	 {   long mid=left+(right-left)/2;
	    		 c= mergeSort(a,b,left,mid);
	    		 c+=mergeSort(a,b,mid+1,right);
	    		 c+=merge(a,b,left,mid+1,right); }
	    		return c;	 }
	    	static long merge(int a[],int  b[],long left,long mid,long right)
	    	{long c=0;int i=(int)left;int j=(int)mid; int k=(int)left;
	    	while(i<=(int)mid-1&&j<=(int)right)
	    	{ if(a[i]>a[j]) {b[k++]=a[i++]; }
	    	else	{ b[k++]=a[j++];c+=mid-i;}}
	    	while (i <= (int)mid - 1)   b[k++] = a[i++];
	    	while (j <= (int)right) b[k++] = a[j++];
	    	for (i=(int)left; i <= (int)right; i++)
	    		a[i] = b[i];  return c;  }
	    	public static boolean isSubSequence(String large, String small, int largeLen, int smallLen) {
	    		//base cases
	    		if (largeLen == 0)
	    			return false;
	    		if (smallLen == 0)
	    			return true;
	    		// If last characters of two strings are matching
	    		if (large.charAt(largeLen - 1) == small.charAt(smallLen - 1))
	    			isSubSequence(large, small, largeLen - 1, smallLen - 1);
	    		// If last characters are not matching
	    		return isSubSequence(large, small, largeLen - 1, smallLen);
	    	}

	    	// To Get Input
	    	// Some Buffer Methods

	    	public static void InputReader(InputStream stream1) {
	    		stream = stream1;
	    	}

	    	private static boolean isWhitespace(int c) {
	    		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    	}

	    	private static boolean isEndOfLine(int c) {
	    		return c == '\n' || c == '\r' || c == -1;
	    	}

	    	private static int read() {
	    		if (numChars == -1)
	    			throw new InputMismatchException();
	    		if (curChar >= numChars) {
	    			curChar = 0;
	    			try {
	    				numChars = stream.read(buf);
	    			} catch (IOException e) {
	    				throw new InputMismatchException();
	    			}
	    			if (numChars <= 0)
	    				return -1;
	    		}
	    		return buf[curChar++];
	    	}

	    	private static int nextInt() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		int sgn = 1;
	    		if (c == '-') {
	    			sgn = -1;
	    			c = read();
	    		}
	    		int res = 0;
	    		do {
	    			if (c < '0' || c > '9')
	    				throw new InputMismatchException();
	    			res *= 10;
	    			res += c - '0';
	    			c = read();
	    		} while (!isSpaceChar(c));
	    		return res * sgn;
	    	}

	    	private static long nextLong() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		int sgn = 1;
	    		if (c == '-') {
	    			sgn = -1;
	    			c = read();
	    		}
	    		long res = 0;
	    		do {
	    			if (c < '0' || c > '9')
	    				throw new InputMismatchException();
	    			res *= 10;
	    			res += c - '0';
	    			c = read();
	    		} while (!isSpaceChar(c));
	    		return res * sgn;
	    	}

	    	private static String nextToken() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		StringBuilder res = new StringBuilder();
	    		do {
	    			res.appendCodePoint(c);
	    			c = read();
	    		} while (!isSpaceChar(c));
	    		return res.toString();
	    	}

	    	private static String nextLine() {
	    		int c = read();
	    		while (isSpaceChar(c))
	    			c = read();
	    		StringBuilder res = new StringBuilder();
	    		do {
	    			res.appendCodePoint(c);
	    			c = read();
	    		} while (!isEndOfLine(c));
	    		return res.toString();
	    	}

	    	private static int[] nextIntArray(int n) {
	    		int[] arr = new int[n];
	    		for (int i = 0; i < n; i++) {
	    			arr[i] = nextInt();
	    		}
	    		return arr;
	    	}

	    	private static int[][] next2dArray(int n, int m) {
	    		int[][] arr = new int[n][m];
	    		for (int i = 0; i < n; i++) {
	    			for (int j = 0; j < m; j++) {
	    				arr[i][j] = nextInt();
	    			}
	    		}
	    		return arr;
	    	}
	    	private static char[][] nextCharArray(int n,int m){
	    		char [][]c=new char[n][m];
	    		for(int i=0;i<n;i++){
	    			String s=nextLine();
	    			for(int j=0;j<s.length();j++){
	    				c[i][j]=s.charAt(j);
	    			}
	    		}
	    		return c;
	    	}

	    	private static long[] nextLongArray(int n) {
	    		long[] arr = new long[n];
	    		for (int i = 0; i < n; i++) {
	    			arr[i] = nextLong();
	    		}
	    		return arr;
	    	}

	    	private static void pArray(int[] arr) {
	    		for (int i = 0; i < arr.length; i++) {
	    			pw.print(arr[i] + " ");
	    		}
	    		pw.println();
	    		return;
	    	}

	    	private static void pArray(long[] arr) {
	    		for (int i = 0; i < arr.length; i++) {
	    			pw.print(arr[i] + " ");
	    		}
	    		pw.println();
	    		return;
	    	}

	    	private static void pArray(boolean[] arr) {
	    		for (int i = 0; i < arr.length; i++) {
	    			pw.print(arr[i] + " ");
	    		}
	    		pw.println();
	    		return;
	    	}

	    	private static boolean isSpaceChar(int c) {
	    		if (filter != null)
	    			return filter.isSpaceChar(c);
	    		return isWhitespace(c);
	    	}

	    	private interface SpaceCharFilter {
	    		public boolean isSpaceChar(int ch);
	    	}

	    	//----------------------------------------My Code------------------------------------------------//
	    	static LinkedList<Integer> adj[];
	    	static boolean visited[];
	    	static int arr[];
	    	static int cou=0;
	    	private static void soln() {
	    		int v=nextInt();
	    		int e=nextInt();
	    		adj=new LinkedList[v];
	    		arr=new int[v];
	    		for(int i=0;i<v;i++){
	    			adj[i]=new LinkedList<Integer>();
	    		}
	    		visited=new boolean[v];
	    		for(int i=0;i<e;i++){
	    			int u=nextInt()-1;
	    			int w=nextInt()-1;
	    			adj[u].add(w);
	    			adj[w].add(u);
	    		}
	    		for(int i=0;i<v;i++){
	    			if(visited[i]!=true){
	    				cou++;
	    				arr[i]=cou;
	    				dfs(i);
	    			}
	    		}
	    		int temp[]=new int[cou];
	    		int i=0;
	    		for( i=0;i<v;i++){
	    			if(temp[arr[i]-1]!=0){
	    				if(adj[i].size()!=temp[arr[i]-1]){
	    					break;
	    				}
	    			}
	    			else{
	    				temp[arr[i]-1]=adj[i].size();
	    			}
	    		}
	    		if(i==v){
	    			pw.println("YES");
	    		}
	    		else pw.println("NO");
	    	}
	    	private static void dfs(int i){
	    		visited[i]=true;
	    		for(int j:adj[i]){
	    			if(visited[j]==false){
	    				arr[j]=cou;
	    				dfs(j);
	    			}
	    		}
	    	}

	    		//-----------------------------------------The End--------------------------------------------------------------------------//

	 }

		class Pair implements Comparable<Pair>{

			int ind;
			int cost;

			Pair(int ind,int len){
				this.cost=ind;
				this.ind=len;
			}
			@Override
			public int compareTo(Pair o) {
				// TODO Auto-generated method stub
			//	Sort in increasing order
				//int result= this.cost.compareTo(o.cost);
				return 0;
			}

		}
	        class  Graph{
	        	private static int V,level[][],count=-1,lev_dfs[],degree=0,no_vert_conn_comp=0;
	        	private Stack <Integer>st=new Stack();
	        	private static LinkedList<Integer > adj[];
	        	private boolean[][] Visite;
	        	private static boolean [] Visited;
	        	private static HashSet<Integer> Vis=new HashSet();
	        	private static Stack<Integer> topo_sort=new Stack<>();
	        	private static HashMap<String,Integer> hm=new HashMap<>();

	    Graph(int V){
	    V++;
	    this.V=(V);
	    adj=new LinkedList[V];
	    Visite=new boolean[100][100];

 	    Visited=new boolean[V];
	    level=new int[100][100];
	    lev_dfs=new int[V];
	   for(int i=0;i<V;i++)
		   adj[i]=new LinkedList<Integer>();

	    }
	    void setup(int n,int m){
	    	//HashMap<String,Integer> hm=new HashMap<>();
    		int co=1;
	    	for(int i=0;i<n;i++){
    			for(int j=0;j<m;j++){
    				String s="";
    				s+=(i)+" "+(j);
    				hm.put(s, co);
    			co++;
    			}
    		}
	    }
	   void addEdge(int v,int w){

	    	if(adj[v]==null){
	    		adj[v]=new LinkedList();
	    	}
	    	adj[v].add(w);

	    }

	 public static void top_ans(){
	while(topo_sort.size()!=0)
{
	System.out.print(hm.get(topo_sort.peek()));
topo_sort.pop();
}

	 }
	 public static void topoSort(int startVert){
		 if(!Vis.contains(startVert)){
			 topoSortUtil(startVert);
		 }
	 }
	    public static void topoSortUtil(int curr_Vert){
	    	Vis.add(curr_Vert);
	    	Iterator<Integer> it=adj[curr_Vert].listIterator();

	    	while(it.hasNext()){
	    		int n=it.next();
	   // 		System.out.println(n);
	    		if(!Vis.contains(n)){
	    			topoSortUtil(n);
	    		}

	    	}
	    	topo_sort.push(curr_Vert);
	    }

	    public static int BFS2(int startVert){
	    	Visited=new boolean[V];
	    	for(int i=1;i<V;i++){
	    		lev_dfs[i]=-1;
	    	}
	    //	System.out.println(startVert);
	    	Queue<Integer> q=new LinkedList<Integer>();
	    	q.add(startVert);

	    	lev_dfs[startVert]=0;
	    	while(!q.isEmpty()){
	    		int top=q.poll();

	    		Iterator<Integer> i= adj[top].listIterator();
	    		while(i.hasNext()){
	    			int n=i.next();
	    	//		System.out.println(top+" "+n);
	    			if(!Visited[n]){
	    				q.add(n);
	    				Visited[n]=true;
	    				lev_dfs[n]=lev_dfs[top]+1;

	    			}
	    		}
	    	}

	    //	q.clear();
	    	return -1;
	    }
	    public static int getAn(int end){
	    	return lev_dfs[end];
	    }
	    public int getEd(){
	    	return degree/2;
	    }
	    public void get(int from,int to){
	    	int h=lev_dfs[from]-lev_dfs[to];
	    	if(h<=0){
	    		System.out.println(-1);
	    	}else{
	    		System.out.println(h-1);
	    	}
	    }
	    private static boolean check(int x,int y,char c[][]){

			if((x>=0 && y>=0) && (x<c.length && y<c[0].length) && c[x][y]!='#'){

				return true;
			}
			return false;
		}
	    public int BFS(int x,int y,int k,char[][] c)
	    {
	    	 LinkedList<Pair> queue = new LinkedList<Pair>();
	        //Visited[s]=true;
	   //     queue.add(new Pair(x,y));
	       int count=0;
	   level[x][y]=-1;
	   c[x][y]='M';
	        while (!queue.isEmpty())
	        {
	            Pair temp = queue.poll();

	        }
	        return V;
	    }

	     public long dfs(int startVertex,int end){
	    //	 getAns(startVertex);
	    	 Visited=new boolean[V];
	    	 if(!Visited[startVertex])  {

	   return dfsUtil(startVertex,end);
	    	//return getAns();
	    	}

	    return 0;
	    	}
	 private long dfsUtil(int startVertex,int end) {//0-Blue 1-Pink
		 int c=1;

		 long cout=0;
	      degree=0;
	    	Visited[startVertex]=true;
	    	lev_dfs[startVertex]=0;
	      st.push(startVertex);
	      int temp=-1;

	    while(!st.isEmpty()){

	    	int top=st.pop();
	    temp=Math.max(temp, top);
	    //	ts.add(top);
	    	Iterator<Integer> i=adj[top].listIterator();

	    while(i.hasNext()){
	    //	System.out.println(top);
	    	int n=i.next();
	     if( !Visited[n]){
	    				Visited[n]=true;

	    			//	col_freq[col[n-1]]++;
	    				c++;
	    				st.push(n);
	    					lev_dfs[n]=lev_dfs[top]+1;
	    					if(n==end){
	    	    				return lev_dfs[n];
	    	    				}
	    		 }
	         }
	 }
	 //   System.out.println(temp);
	    if(lev_dfs[temp]+(end-temp)<=0){
	    	return end-startVertex;
	    }
	    return Math.min(end-startVertex, lev_dfs[temp]+(end-temp));

	    }

	        }

	    class Dsu{
	    	private int rank[], parent[] ,n;

	    	Dsu(int size){
	    		this.n=size+1;
	    		rank=new int[n];
	    		parent=new int[n];
	    	makeSet();
	    	}

	    	void makeSet(){
	    		for(int i=0;i<n;i++){
	    			parent[i]=i;
	    		}
	    	}

	    	int find(int x){
	    		if(parent[x]!=x){

	    			parent[x]=find(parent[x]);
	    		}
	    		return parent[x];
	    	}

	    	void union(int x,int y){
	    		int xRoot=find(x);
	    		int yRoot=find(y);

	    		if(xRoot==yRoot)
	    			return;
	    		if(rank[xRoot]<rank[yRoot]){
	    		parent[xRoot]=yRoot;
	    		}else if(rank[yRoot]<rank[xRoot]){
	    			parent[yRoot]=xRoot;
	    		}else{
	    			parent[yRoot]=xRoot;
	    			rank[xRoot]++;
	    		}

	    	}

	    }
	    class Heap{

	    	public static void build_max_heap(long []a,int size){

	    		for(int i=size/2;i>0;i--){
	    			max_heapify(a, i,size);
	    		}

	    			}
	    	private static void max_heapify(long[] a,int i,int size){
	    		int left_child=2*i;
	    		int right_child=(2*i+1);
	    		int largest=0;

	    		if(left_child<size && a[left_child]>a[i]){
	    			largest=left_child;
	    		}else{
	    			largest=i;
	    		}

	    		if(right_child<size && a[right_child]>a[largest]){
	    			largest=right_child;
	    		}
	    		if(largest!=i){
	    			long temp=a[largest];
	    			a[largest]=a[i];
	    			a[i]=temp;
	    			max_heapify(a, largest,size);
	    		}
	    	}
	    	private static void min_heapify(int[] a,int i){
	    		int left_child=2*i;
	    		int right_child=(2*i+1);
	    		int largest=0;

	    		if(left_child<a.length && a[left_child]<a[i]){
	    			largest=left_child;
	    		}else{
	    			largest=i;
	    		}

	    		if(right_child<a.length && a[right_child]<a[largest]){
	    			largest=right_child;
	    		}
	    		if(largest!=i){
	    			int temp=a[largest];
	    			a[largest]=a[i];
	    			a[i]=temp;
	    			min_heapify(a, largest);
	    		}
	    	}
	    	public static void extract_max(int size,long a[]){
	    		if(a.length>1){
	    			long max=a[1];
	    			a[1]=a[a.length-1];
	    			size--;
	    			max_heapify(a, 1,a.length-1);
	    		}
	    	}
	    }

	    class MyComp implements Comparator<Long>{

			@Override
			public int compare(Long o1, Long o2) {
				if(o1<o2){
					return 1;
				}else if(o1>o2){
					return -1;
				}
				return 0;

			}
	    }


import java.util.*;
import java.io.*;

public class TestClass{
    static ArrayList<Integer>[] al2;
         static class Pair implements Comparator<Pair>{
  int a;
  int b;
  Pair(){

  }

  Pair(int a,int b){
    this.a=a;
    this.b=b;
  }
  public int compare(Pair p1,Pair p2){

    return p1.a-p2.a;
 }
}

   static InputReader sc = new InputReader();
   static int gcd(int a,int b){
    if(a==0){
      return b;
    }
    return gcd(b%a,a);
   }
   static int d;
   static int[] color;
   static boolean[] v;
    /*static void dfs(int src,int x,int y){
      v[src]=true;
     int  i=1;
     color[src]=x;
      for(int a :al[src]){
        if(v[a]) continue;
        if(i==x|| i==y){
          i++;
          if(i==x|| i==y){
          i++;
        }
        }
        color[a]=i;
        i++;

      }
      for(int a:al[src]){
        if(!v[a]){
          dfs(a,color[a],x);
        }
      }

    }

*/
public static boolean isvowel(char ch){
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
        return true;
    }else{
        return false;
    }
}

 static ArrayList<Integer>[] al;
static int n;
static int[] level;
static boolean[] visited;

    public static void main(String[] args) throws IOException{
      n=i(); int m=i();
            al=new ArrayList[n+1];
            level=new int[n+1];
            visited=new boolean[n+1];
         for (int i=0;i<=n ;i++ ) {
             al[i]=new ArrayList<Integer>();
           }
         for(int i=0;i<m;i++){
          int a=i();
          int b=i();
          al[a].add(b);
          al[b].add(a);
         }

         boolean[] b=new boolean[n+1];
          for(int i=1;i<=n;i++){
              if(!visited[i]){
                 dfs(i,-1);
                 if(count!=0 && count1!=0 &&count==(count1*count1-1)/2){
            System.out.println("YES");
                  }else if(count!=0 && count1!=0){
            System.out.println("NO");
          }
              }
              count1=0;
              count=0;
          }

      }
      static int count=0;static int count1=0;
      public static void dfs(int node,int parent){
          visited[node]=true;
            count1++;
          for(int i:al[node]){
            if(i!=parent)count++;

            if(!visited[i]){

                dfs(i,node);
              }
          }
      }

    /////////////////////////////////////////////////////////// shortcuts //////////////////////////////
  /*    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result = 1;
        while (exp > 0) {
            if (exp % 2 == 1) {
                result = (result * base) % mod;
                exp--;
            } else {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    public static void cal() {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++) {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }
 */
   /* public static long ncr(int n, int r) {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }
 */

      static int i() {

          return sc.nextInt();
        }
        static long l() throws IOException{
          return sc.nextLong();

        }
        static double d() throws IOException{
          return sc.nextDouble();
        }
        static String s() throws IOException{
          return sc.next();

        }
        static String sL() throws IOException{
          return sc.nextLine();
        }
       static void loop(int[] a) throws IOException{
          for(int j=0;j<a.length;j++){
              a[j]=i();
          }
        }
        static void eloop(int[] a) throws IOException{
          for(int i=1;i<=a.length;i++){
              a[i]=i();
          }
        }
        static void ploop(int[] a)throws IOException{
             for(int j=0;j<a.length;j++){
                System.out.println(a[j]);
             }

        }
        static void eploop(int[] a)throws IOException{
             for(int j=1;j<=a.length;j++){
                System.out.println(a[j]);
             }

        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////

  static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }

 }


import java.util.*;
import java.io.*;

  public class TestClass{
    static ArrayList<Integer>[] al2;
         static class Pair implements Comparator<Pair>{
  int a;
  int b;
  Pair(){

  }

  Pair(int a,int b){
    this.a=a;
    this.b=b;
  }
  public int compare(Pair p1,Pair p2){

    return p1.a-p2.a;
 }
}

   static InputReader sc = new InputReader();
   static int gcd(int a,int b){
    if(a==0){
      return b;
    }
    return gcd(b%a,a);
   }
   static int d;
   static int[] color;
   static boolean[] v;
    /*static void dfs(int src,int x,int y){
      v[src]=true;
     int  i=1;
     color[src]=x;
      for(int a :al[src]){
        if(v[a]) continue;
        if(i==x|| i==y){
          i++;
          if(i==x|| i==y){
          i++;
        }
        }
        color[a]=i;
        i++;

      }
      for(int a:al[src]){
        if(!v[a]){
          dfs(a,color[a],x);
        }
      }

    }

*/
public static boolean isvowel(char ch){
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
        return true;
    }else{
        return false;
    }
}

 static ArrayList[] al;
static int n;
static int[] level;
static boolean[] visited;

    public static void main(String[] args) throws IOException{
      n=i(); int m=i();
            al=new ArrayList[n+1];
            level=new int[n+1];
            visited=new boolean[n+1];
         for (int i=0;i<=n ;i++ ) {
             al[i]=new ArrayList();
           }
         for(int i=0;i<m;i++){
          int a=i();
          int b=i();
          al[a].add(b);
          al[b].add(a);
         }
         boolean[] b=new boolean[n+1];
          for(int i=1;i<=n;i++){
              if(!visited[i]){
                  Bfs(i);

                   visited=new boolean[n+1];

                  if(!Dfs(i)){

                    System.out.println("NO");
                    return;
                  }level=new int[n+1];

              }
          }

 System.out.println("YES");
 return;

      }
       public static boolean Dfs(int node){
          int flag=0;
    visited[node]=true;

    if(level[node]>1){return false;
}    Iterator i=al[node].listIterator();

    while(i.hasNext()){
      int x=(int)i.next();
      if(!visited[x]){
        if(!Dfs(x)){
         flag=1;
         break;
        }
      }
    }
    if(flag==0){
      return true;
    }else{
      return false;
    }

  }
           public static void Bfs(int node){

          Queue q=new LinkedList();
          visited[node]=true;
          q.add(node);
          while(!q.isEmpty()){

              int x=(int)q.remove();

              visited[x]=true;
              Iterator i=al[x].listIterator();

              while(i.hasNext()){
                int m=(int)i.next();
                if(visited[m]==false){
                q.add(m);
                level[m]=1+level[x];
                visited[m]=true;
              }
              }

        }
      }

    /////////////////////////////////////////////////////////// shortcuts //////////////////////////////
  /*    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result = 1;
        while (exp > 0) {
            if (exp % 2 == 1) {
                result = (result * base) % mod;
                exp--;
            } else {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    public static void cal() {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++) {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }
 */
   /* public static long ncr(int n, int r) {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }
 */

      static int i() {

          return sc.nextInt();
        }
        static long l() throws IOException{
          return sc.nextLong();

        }
        static double d() throws IOException{
          return sc.nextDouble();
        }
        static String s() throws IOException{
          return sc.next();

        }
        static String sL() throws IOException{
          return sc.nextLine();
        }
       static void loop(int[] a) throws IOException{
          for(int j=0;j<a.length;j++){
              a[j]=i();
          }
        }
        static void eloop(int[] a) throws IOException{
          for(int i=1;i<=a.length;i++){
              a[i]=i();
          }
        }
        static void ploop(int[] a)throws IOException{
             for(int j=0;j<a.length;j++){
                System.out.println(a[j]);
             }

        }
        static void eploop(int[] a)throws IOException{
             for(int j=1;j<=a.length;j++){
                System.out.println(a[j]);
             }

        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////

  static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }

 }


import java.util.*;
import java.io.*;

 public class TestClass{
    static ArrayList<Integer>[] al2;
         static class Pair implements Comparator<Pair>{
  int a;
  int b;
  Pair(){

  }

  Pair(int a,int b){
    this.a=a;
    this.b=b;
  }
  public int compare(Pair p1,Pair p2){

    return p1.a-p2.a;
 }
}

   static InputReader sc = new InputReader();
   static int gcd(int a,int b){
    if(a==0){
      return b;
    }
    return gcd(b%a,a);
   }
   static int d;
   static int[] color;
   static boolean[] v;
    /*static void dfs(int src,int x,int y){
      v[src]=true;
     int  i=1;
     color[src]=x;
      for(int a :al[src]){
        if(v[a]) continue;
        if(i==x|| i==y){
          i++;
          if(i==x|| i==y){
          i++;
        }
        }
        color[a]=i;
        i++;

      }
      for(int a:al[src]){
        if(!v[a]){
          dfs(a,color[a],x);
        }
      }

    }

*/
public static boolean isvowel(char ch){
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
        return true;
    }else{
        return false;
    }
}

 static ArrayList<Integer>[] al;
static int n;
static int[] level;
static boolean[] visited;

    public static void main(String[] args) throws IOException{
      n=i(); int m=i();
            al=new ArrayList[n+1];
            level=new int[n+1];
            visited=new boolean[n+1];
         for (int i=0;i<=n ;i++ ) {
             al[i]=new ArrayList<Integer>();
           }
         for(int i=0;i<m;i++){
          int a=i();
          int b=i();
          al[a].add(b);
          al[b].add(a);
         }

         boolean[] b=new boolean[n+1];
          for(int i=1;i<=n;i++){
              if(!visited[i]){
                 dfs(i,-1);
                 if(count!=0 && count1>1 && count!=(count1*count1-1)/2){
            System.out.println("NO");
            return;
          }   count1=0;
              count=0;
              }

          }

            System.out.println("YES");

      }
      static int count=0;static int count1=0;
      public static void dfs(int node,int parent){
          visited[node]=true;
            count1++;
          for(int i:al[node]){
            if(i!=parent)count++;

            if(!visited[i]){

                dfs(i,node);
              }
          }
      }

    /////////////////////////////////////////////////////////// shortcuts //////////////////////////////
  /*    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result = 1;
        while (exp > 0) {
            if (exp % 2 == 1) {
                result = (result * base) % mod;
                exp--;
            } else {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    public static void cal() {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++) {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }
 */
   /* public static long ncr(int n, int r) {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }
 */

      static int i() {

          return sc.nextInt();
        }
        static long l() throws IOException{
          return sc.nextLong();

        }
        static double d() throws IOException{
          return sc.nextDouble();
        }
        static String s() throws IOException{
          return sc.next();

        }
        static String sL() throws IOException{
          return sc.nextLine();
        }
       static void loop(int[] a) throws IOException{
          for(int j=0;j<a.length;j++){
              a[j]=i();
          }
        }
        static void eloop(int[] a) throws IOException{
          for(int i=1;i<=a.length;i++){
              a[i]=i();
          }
        }
        static void ploop(int[] a)throws IOException{
             for(int j=0;j<a.length;j++){
                System.out.println(a[j]);
             }

        }
        static void eploop(int[] a)throws IOException{
             for(int j=1;j<=a.length;j++){
                System.out.println(a[j]);
             }

        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////

  static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }

 }


import java.util.*;
import java.io.*;

public  class TestClass{
    static ArrayList<Integer>[] al2;
         static class Pair implements Comparator<Pair>{
  int a;
  int b;
  Pair(){

  }

  Pair(int a,int b){
    this.a=a;
    this.b=b;
  }
  public int compare(Pair p1,Pair p2){

    return p1.a-p2.a;
 }
}

   static InputReader sc = new InputReader();
   static int gcd(int a,int b){
    if(a==0){
      return b;
    }
    return gcd(b%a,a);
   }
   static int d;
   static int[] color;
   static boolean[] v;
    /*static void dfs(int src,int x,int y){
      v[src]=true;
     int  i=1;
     color[src]=x;
      for(int a :al[src]){
        if(v[a]) continue;
        if(i==x|| i==y){
          i++;
          if(i==x|| i==y){
          i++;
        }
        }
        color[a]=i;
        i++;

      }
      for(int a:al[src]){
        if(!v[a]){
          dfs(a,color[a],x);
        }
      }

    }

*/
public static boolean isvowel(char ch){
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
        return true;
    }else{
        return false;
    }
}

 static ArrayList<Pair>[] al;
static int n;
static int[] level;
static boolean[] visited;
static boolean[] edge;

    public static void main(String[] args) throws IOException{
      n=i(); int m=i();
            al=new ArrayList[n+1];
            level=new int[n+1];
            visited=new boolean[n+1];
            edge=new boolean[m+1];
         for (int i=0;i<=n ;i++ ) {
             al[i]=new ArrayList<Pair>();
           }

         for(int i=0;i<m;i++){
          int a=i();
          int b=i();
          al[a].add(new Pair(b,i+1));
          al[b].add(new Pair(a,i+1));
         }

         boolean[] b=new boolean[n+1];
          for(int i=1;i<=n;i++){
              if(!visited[i]){
                 dfs(i,-1);
                 if(count1>1 && count!=(count1*(count1-1))/2){
                        System.out.println( "NO" );
                        return;
          }   count1=0;
              count=0;
              }

          }

            System.out.println("YES");

      }
      static int count=0;static int count1=0;
      public static void dfs(int node,int parent){
          visited[node]=true;
            count1++;
          for(Pair p:al[node]){
            if(!edge[p.b]){count++;edge[p.b]=true;}

            if(!visited[p.a]){

                dfs(p.a,node);
              }
          }
      }

    /////////////////////////////////////////////////////////// shortcuts //////////////////////////////
  /*    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result = 1;
        while (exp > 0) {
            if (exp % 2 == 1) {
                result = (result * base) % mod;
                exp--;
            } else {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    public static void cal() {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++) {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }
 */
   /* public static long ncr(int n, int r) {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }
 */

      static int i() {

          return sc.nextInt();
        }
        static long l() throws IOException{
          return sc.nextLong();

        }
        static double d() throws IOException{
          return sc.nextDouble();
        }
        static String s() throws IOException{
          return sc.next();

        }
        static String sL() throws IOException{
          return sc.nextLine();
        }
       static void loop(int[] a) throws IOException{
          for(int j=0;j<a.length;j++){
              a[j]=i();
          }
        }
        static void eloop(int[] a) throws IOException{
          for(int i=1;i<=a.length;i++){
              a[i]=i();
          }
        }
        static void ploop(int[] a)throws IOException{
             for(int j=0;j<a.length;j++){
                System.out.println(a[j]);
             }

        }
        static void eploop(int[] a)throws IOException{
             for(int j=1;j<=a.length;j++){
                System.out.println(a[j]);
             }

        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////

  static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }

 }


import java.util.*;
import java.io.*;

 public class TestClass{
    static ArrayList<Integer>[] al2;
         static class Pair implements Comparator<Pair>{
  int a;
  int b;
  Pair(){

  }

  Pair(int a,int b){
    this.a=a;
    this.b=b;
  }
  public int compare(Pair p1,Pair p2){

    return p1.a-p2.a;
 }
}

   static InputReader sc = new InputReader();
   static int gcd(int a,int b){
    if(a==0){
      return b;
    }
    return gcd(b%a,a);
   }
   static int d;
   static int[] color;
   static boolean[] v;
    /*static void dfs(int src,int x,int y){
      v[src]=true;
     int  i=1;
     color[src]=x;
      for(int a :al[src]){
        if(v[a]) continue;
        if(i==x|| i==y){
          i++;
          if(i==x|| i==y){
          i++;
        }
        }
        color[a]=i;
        i++;

      }
      for(int a:al[src]){
        if(!v[a]){
          dfs(a,color[a],x);
        }
      }

    }

*/
public static boolean isvowel(char ch){
    if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
        return true;
    }else{
        return false;
    }
}

 static ArrayList<Pair>[] al;
static int n;
static int[] level;
static boolean[] visited;
static boolean[] edge;

    public static void main(String[] args) throws IOException{
      n=i(); int m=i();
            al=new ArrayList[n+1];
            level=new int[n+1];
            visited=new boolean[n+1];
            edge=new boolean[m+1];
         for (int i=0;i<=n ;i++ ) {
             al[i]=new ArrayList<Pair>();
           }

         for(int i=0;i<m;i++){
          int a=i();
          int b=i();
          al[a].add(new Pair(b,i+1));
          al[b].add(new Pair(a,i+1));
         }

         boolean[] b=new boolean[n+1];
          for(int i=1;i<=n;i++){
              if(!visited[i]){
                 dfs(i,-1);
                 if(count1>1 && count!=(count1*(count1-1))/2){
                        System.out.println( "NO" );
                        return;
          }   count1=0;
              count=0;
              }

          }

            System.out.println("YES");

      }
      static long count=0;static long count1=0;
      public static void dfs(int node,int parent){
          visited[node]=true;
            count1++;
          for(Pair p:al[node]){
            if(!edge[p.b]){count++;edge[p.b]=true;}

            if(!visited[p.a]){

                dfs(p.a,node);
              }
          }
      }

    /////////////////////////////////////////////////////////// shortcuts //////////////////////////////
  /*    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result = 1;
        while (exp > 0) {
            if (exp % 2 == 1) {
                result = (result * base) % mod;
                exp--;
            } else {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

    public static void cal() {
        fac = new long[1000005];
        inv = new long[1000005];
        fac[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= 1000000; i++) {
            fac[i] = (fac[i - 1] * i) % mod;
            inv[i] = (inv[i - 1] * modPow(i, mod - 2, mod)) % mod;
        }
    }
 */
   /* public static long ncr(int n, int r) {
        return (((fac[n] * inv[r]) % mod) * inv[n - r]) % mod;
    }
 */

      static int i() {

          return sc.nextInt();
        }
        static long l() throws IOException{
          return sc.nextLong();

        }
        static double d() throws IOException{
          return sc.nextDouble();
        }
        static String s() throws IOException{
          return sc.next();

        }
        static String sL() throws IOException{
          return sc.nextLine();
        }
       static void loop(int[] a) throws IOException{
          for(int j=0;j<a.length;j++){
              a[j]=i();
          }
        }
        static void eloop(int[] a) throws IOException{
          for(int i=1;i<=a.length;i++){
              a[i]=i();
          }
        }
        static void ploop(int[] a)throws IOException{
             for(int j=0;j<a.length;j++){
                System.out.println(a[j]);
             }

        }
        static void eploop(int[] a)throws IOException{
             for(int j=1;j<=a.length;j++){
                System.out.println(a[j]);
             }

        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////

  static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                throw new RuntimeException();
            }
            return str;
        }
    }

 }