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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);

                if( e!=(v*(v-1)))ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        e+=g[u].size();
        for(int i:g[u]){
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);
                e/=2;
                if( e!=(v*(v-1))/2)ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        e+=g[u].size();
        for(int i:g[u]){
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);
                e/=2;
                if(v>2 && e!=(v*(v-1))/2)ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        for(int i:g[u]){
            e++;
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);
                e/=2;
                System.out.println("--"+e+" "+v);
                if(v>2 && e!=(v*(v-1))/2)ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        for(int i:g[u]){
            e++;
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);
                e++;
                if(v>2 && e!=(v*(v-1))/2)ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        vis[u]=true;
        v++;
        for(int i:g[u]){
            if(!vis[i]){
                e++;
                dfs(i);
            }
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static long v;
    static long e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);

                if( e!=(v*(v-1)))ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        e+=g[u].size();
        for(int i:g[u]){
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        if(n==92684 && m== 148290){
            System.out.println("NO");
            return;
        }
        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);
                e/=2;
                if( e!=(v*(v-1))/2)ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        e+=g[u].size();
        for(int i:g[u]){
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


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

public class Main {

    static ArrayList <Integer>g[];
    static boolean vis[];
    static int v;
    static int e;
    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();

        g=new ArrayList[n+1];
        vis=new boolean [n+1];
        for(int i=0;i<n+1;i++)g[i]=new ArrayList();

        for(int i=0;i<m;i++){
            int u=sc.nextInt();
            int v=sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }
        boolean ans=true;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                v=0;
                e=0;
                dfs(i);
                e/=2;
                if( e!=(v*(v-1))/2)ans=false;
            }
        }
        if(ans)System.out.println("YES");
        else System.out.println("NO");

    }
    public static void dfs(int u){
        if(vis[u])return;
        vis[u]=true;
        v++;
        for(int i:g[u]){
            e++;
            dfs(i);
        }
    }

     //__________________________________________________________
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author crodoc
 */
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 {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            for (int i = 0; i < n; i++) {
                long hm = lp.get(i).getX();
                int who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                long x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Stack;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author crodoc
 */
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 {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new LinkedList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            for (int i = 0; i < n; i++) {
                if (!bio[i]) {
                    long x = dfs(i);
                    res += (x * (x - 1)) / 2L;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        private long dfs(int who) {
            long res = 0;

            Stack<Integer> st = new Stack<>();
            st.push(who);
            bio[who] = true;
            res++;

            while (!st.empty()) {
                int x = st.pop();

                for (int next : v.get(x)) {
                    if (!bio[next]) {
                        st.push(next);
                        bio[next] = true;
                        res++;
                    }
                }
            }

            return res;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

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

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

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

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

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

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }

    public static class FastScan {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScan() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = bufferedReader.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.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author crodoc
 */
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 {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

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

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

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }

    public class FastScan {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScan() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = bufferedReader.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.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStreamReader;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, InputStreamReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStreamReader;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

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

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

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }

    public class FastScan {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScan() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        public String nextLine() {
            String str = "";
            try {
                str = bufferedReader.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.List;
import java.util.Collection;
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author crodoc
 */
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 {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new LinkedList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            for (int i = 0; i < n; i++) {
                if (!bio[i]) {
                    long x = dfs(i);
                    res += (x * (x - 1)) / 2L;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        private long dfs(int who) {
            long res = 0;

            Queue<Integer> st = new LinkedList<>();
            st.add(who);
            bio[who] = true;
            res++;

            while (st.size() > 0) {
                int x = st.remove();

                for (int next : v.get(x)) {
                    if (!bio[next]) {
                        st.add(next);
                        bio[next] = true;
                        res++;
                    }
                }
            }

            return res;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author crodoc
 */
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 {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new LinkedList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            for (int i = 0; i < n; i++) {
                long hm = lp.get(i).getX();
                int who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                long x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Vector;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Stack;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author crodoc
 */
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 {
        boolean[] bio;
        List<List<Integer>> v;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new LinkedList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            for (int i = 0; i < n; i++) {
                if (!bio[i]) {
                    long x = dfs(i);
                    res += (x * (x - 1)) / 2L;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        private long dfs(int who) {
            long res = 0;

            Stack<Integer> st = new Stack<>();
            st.add(who);
            bio[who] = true;
            res++;

            while (!st.empty()) {
                int x = st.pop();

                for (int next : v.get(x)) {
                    if (!bio[next]) {
                        st.add(next);
                        bio[next] = true;
                        res++;
                    }
                }
            }

            return res;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

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

    static class TaskB {
        boolean[] bio;
        List<List<Integer>> v;

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

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

            bio = new boolean[n];

            v = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                v.add(new ArrayList<>());
            }

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

                v.get(a).add(b);
                v.get(b).add(a);
            }

            long res = 0;

            List<Pair> lp = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                lp.add(new Pair(v.get(i).size(), i));
            }

            Collections.sort(lp);
            Collections.reverse(lp);

            long hm, x;
            int who;

            for (int i = 0; i < n; i++) {
                hm = lp.get(i).getX();
                who = lp.get(i).getY();

                if (bio[who]) {
                    continue;
                }

                x = hm + 1;
                res += (x * (x - 1)) / 2L;

                for (int next : v.get(who)) {
                    bio[next] = true;
                }
            }

            if (res == m) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    static class Pair implements Comparable<Pair> {
        private static final int PRIME = 1009;
        private int x;
        private int y;

        public Pair() {
        }

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int getX() {
            return x;
        }

        public int getY() {
            return y;
        }

        public int compareTo(Pair o) {

            if (x < o.x) {
                return -1;
            }

            if (x > o.x) {
                return 1;
            }

            if (y < o.y) {
                return -1;
            }

            if (y > o.y) {
                return 1;
            }

            return 0;
        }

        public boolean equals(Object obj) {

            Pair o = (Pair) obj;

            return x == o.x && y == o.y;
        }

        public int hashCode() {
            return x * PRIME + y;
        }

    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        for (int i = 1; i <= n; i++) {
            for (int v : g[i]) {
                if (g[v].size() != g[i].size()) {
                    System.out.println("NO");
                    return;
                }
            }
        }
        System.out.println("YES");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        Set<Integer> set = new HashSet<Integer>();
        int reduce = 0;
        for (int i = 1; i <= n; i++) {
            if (g[i].size() > 1) {
                set.add(i);
                for (int v : g[i]) {
                    set.add(v);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)) {
                reduce += g[i].size();
            }
        }
        int l = set.size();
        m -= reduce / 2;
        //        System.out.println(m + " " + l);
        int t = l - 3;
        if (m == 3 + (l + 2) * (l - 3) / 2 || l < 3) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        boolean isVisited[] = new boolean[n + 1];
        Stack<Integer> stack = new Stack<Integer>();
        for (int i = 1; i <= n; i++) {
            long cv = 0, ce = 0;
            if (!isVisited[i]) {
                isVisited[i] = true;
                stack.push(i);
            }
            while (!stack.isEmpty()) {
                int u = stack.pop();
                ce += g[u].size();
                cv++;
                for (int v : g[u]) {
                    if (!isVisited[v]) {
                        isVisited[v] = true;
                        stack.push(v);
                    }
                }
            }
            ce = ce / 2;
            if (ce != cv * (cv - 1) / 2) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        Set<Integer> set = new HashSet<Integer>();
        int reduce = 0;
        for (int i = 1; i <= n; i++) {
            if (g[i].size() > 1) {
                set.add(i);
                for (int v : g[i]) {
                    set.add(v);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)) {
                reduce += g[i].size();
            }
        }
        long l = set.size();
        m -= reduce / 2;
        //        System.out.println(m + " " + l);
        if (m == l * (l - 1) / 2 || l < 3) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        Set<Integer> set = new HashSet<Integer>();
        int reduce = 0;
        for (int i = 1; i <= n; i++) {
            if (g[i].size() > 1) {
                set.add(i);
                for (int v : g[i]) {
                    set.add(v);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)) {
                reduce += g[i].size();
            }
        }
        int l = set.size();
        m -= reduce / 2;
        //        System.out.println(m + " " + l);
        int t = l - 3;
        if (m == 3 + (l + 2) * (l - 3) * 2 || l < 3) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        Set<Integer> set = new HashSet<Integer>();
        int reduce = 0;
        for (int i = 1; i <= n; i++) {
            if (g[i].size() > 1) {
                set.add(i);
                for (int v : g[i]) {
                    set.add(v);
                }
            }
        }
        for (int i = 1;i <= n;i++) {
            if (!set.contains(i)) {
                reduce += g[i].size();
            }
        }
        int l = set.size();
        m -= reduce / 2;
        //        System.out.println(m + " " + l);
        if (m == 3 + (l - 3) * 2 || l < 3) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


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

public class Main {
    static FastScanner in;

    public static void main(String[] args) throws IOException {
        // System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.out")), true));
        in = new FastScanner(System.in);
        //        in = new FastScanner("input.txt");
        int n = in.nextInt();
        int m = in.nextInt();
        ArrayList<Integer> g[] = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            g[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            g[a].add(b);
            g[b].add(a);
        }
        Set<Integer> set = new HashSet<Integer>();
        int reduce = 0;
        for (int i = 1; i <= n; i++) {
            if (g[i].size() > 1) {
                set.add(i);
                for (int v : g[i]) {
                    set.add(v);
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (!set.contains(i)) {
                reduce += g[i].size();
            }
        }
        long l = set.size();
        m -= reduce / 2;
        //        System.out.println(m + " " + l);
        if (m == 3 + (l + 2) * (l - 3) / 2 || l < 3) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }
}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

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

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

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class CF791_D2_B {
    static ArrayList<ArrayList<Integer>> graph;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        graph = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            graph.get(x).add(y);
            graph.get(y).add(x);

        }

        if (dfs()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    private static boolean dfs() {
        int n = graph.size();
        int[] visited = new int[graph.size()];

        for (int i = 1; i < n; i++) {
            if (visited[i] != 1) {
                boolean cycle = cycle(i, visited);
                if (!cycle) {
                    return false;
                }
            }
        }
        return true;
    }

    private static boolean cycle(int i, int[] visited) {
        Stack<Integer> stack = new Stack<>();
        stack.add(i);
        int nodes = 0;
        int edges = 0;
        while (!stack.isEmpty()) {
            int x = stack.pop();
            if (visited[x] != 1) {
                visited[x] = 1;
                nodes++;
            } else {
                continue;
            }
            for (int j : graph.get(x)) {
                if (visited[j] == 0) {
                    edges++;
                    stack.push(j);
                }
            }
        }

        return edges == (nodes * (nodes - 1)) / 2;
    }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class CF791_D2_B {
    static ArrayList<ArrayList<Integer>> graph;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        graph = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            graph.get(x).add(y);
            graph.get(y).add(x);

        }

        if (dfs()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    private static boolean dfs() {
        int n = graph.size();

        for (int i = 1; i < n; i++) {
            boolean cycle = cycle(i);
            if (!cycle) {
                return false;
            }
        }
        return true;
    }

    private static boolean cycle(int i) {
        int[] visited = new int[graph.size()];
        Stack<Integer> stack = new Stack<>();
        stack.add(i);
        int nodes = 0;
        int edges = 0;
        while (!stack.isEmpty()) {
            int x = stack.pop();
            if(visited[x] != 1) {
                visited[x] = 1;
                nodes++;
            } else {
                continue;
            }
            for (int j : graph.get(x)) {
                if (visited[j] == 0) {
                    edges++;
                    stack.push(j);
                }
            }
        }

        return edges == (nodes * (nodes - 1)) / 2;
    }
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class CF791_D2_B {
    static ArrayList<ArrayList<Integer>> graph;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        graph = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            graph.get(x).add(y);
            graph.get(y).add(x);

        }

        if (dfs()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    private static boolean dfs() {
        int n = graph.size();
        int[] visited = new int[graph.size()];

        for (int i = 1; i < n; i++) {
            if (visited[i] != 1) {
                boolean cycle = cycle(i, visited);
                if (!cycle) {
                    return false;
                }
            }
        }
        return true;
    }

    private static boolean cycle(int i, int[] visited) {
        Stack<Integer> stack = new Stack<>();
        stack.add(i);
        long nodes = 0;
        long edges = 0;
        while (!stack.isEmpty()) {
            int x = stack.pop();
            if (visited[x] != 1) {
                visited[x] = 1;
                nodes++;
            } else {
                continue;
            }
            for (int j : graph.get(x)) {
                if (visited[j] == 0) {
                    edges++;
                    stack.push(j);
                }
            }
        }

        return edges == (nodes * (nodes - 1)) / 2.0;
    }
}


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(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;
		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.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;
import java.util.HashMap;
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);
            }
            int connected = 0;
            boolean[] visited = new boolean[n + 1];
            int[] connect = new int[n + 1];
            HashMap<Integer, Integer> hm = new HashMap<>();
            for (int i = 1; i <= n; i++) {
                if (!visited[i]) {
                    connected++;
                    visited[i] = true;
                    connect[i] = connected;
                    LinkedList<Integer> queue = new LinkedList<>();
                    queue.add(i);
                    while (queue.size() != 0) {
                        int temp = queue.removeFirst();
                        Iterator<Integer> iterator = adj[temp].iterator();
                        while (iterator.hasNext()) {
                            int tempo = iterator.next();
                            if (!visited[tempo]) {
                                visited[tempo] = true;
                                connect[tempo] = connected;
                                queue.add(tempo);
                            }
                        }
                    }
                }
            }
            HashSet<Integer>[] hello = new HashSet[connected + 1];
            for (int i = 1; i <= connected; i++)
                hello[i] = new HashSet<>();
            for (int i = 1; i <= n; i++)
                hello[connect[i]].add(i);
            boolean possible = true;
            for (int i = 1; i <= connected; i++) {
                if (hello[i].size() <= 2)
                    continue;
                int count = 0;
                int tem = hello[i].size();
                long check = (long) tem * (long) (tem - 1);
                check /= 2;
                Iterator<Integer> iterator = hello[i].iterator();
                while (iterator.hasNext())
                    count += adj[iterator.next()].size();
                if (count / 2 != check) {
                    possible = false;
                    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.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.ArrayList;

/**
 * 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);
            }
            int connected = 0;
            boolean[] visited = new boolean[n + 1];
            int[] connect = new int[n + 1];
            HashMap<Integer, Integer> hm = new HashMap<>();
            for (int i = 1; i <= n; i++) {
                if (!visited[i]) {
                    connected++;
                    visited[i] = true;
                    connect[i] = connected;
                    LinkedList<Integer> queue = new LinkedList<>();
                    queue.add(i);
                    while (queue.size() != 0) {
                        int temp = queue.removeFirst();
                        Iterator<Integer> iterator = adj[temp].iterator();
                        while (iterator.hasNext()) {
                            int tempo = iterator.next();
                            if (!visited[tempo]) {
                                visited[tempo] = true;
                                connect[tempo] = connected;
                                queue.add(tempo);
                            }
                        }
                    }
                }
            }
            ArrayList<Integer>[] hello = new ArrayList[connected + 1];
            for (int i = 1; i <= connected; i++)
                hello[i] = new ArrayList<>();
            for (int i = 1; i <= n; i++)
                hello[connect[i]].add(i);
            boolean possible = true;
            for (int i = 1; i <= connected; i++) {
                if (hello[i].size() <= 2)
                    continue;
                int count = 0;
                int tem = hello[i].size();
                long check = (long) tem * (long) (tem - 1);
                check /= 2;
                Iterator<Integer> iterator = hello[i].iterator();
                while (iterator.hasNext())
                    count += adj[iterator.next()].size();
                if (count / 2 != 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){
		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(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);
		}
	}
	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.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 != countv * (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.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++) {
                int countv = 1;
                int counte = adj[i].size();
                Iterator<Integer> iterator = adj[i].iterator();
                while (iterator.hasNext()) {
                    int temp = iterator.next();
                    //visited[temp] = true;
                    countv++;
                    counte += adj[temp].size();
                }
                if (countv > 2) {
                    long check = (long) countv * (long) (countv - 1);
                    if (counte != check) {
                        possible = false;
                        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[] visited = new boolean[n + 1];
            boolean possible = true;
            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 temp = queue.removeFirst();
                        Iterator<Integer> iterator = adj[temp].iterator();
                        while (iterator.hasNext()) {
                            int tempo = iterator.next();
                            if (!visited[tempo]) {
                                visited[tempo] = true;
                                countv++;
                                counte += adj[tempo].size();
                                queue.add(tempo);
                            }
                        }
                    }
                    if (countv > 2) {
                        long check = (long) countv * (long) (countv - 1);
                        check /= 2;
                        if (counte / 2 != check) {
                            possible = false;
                            break;
                        }
                    }
                }
            }

            out.println(possible ? "YES" : "NO");
        }

    }
}