#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
const int MOD = 1e9 + 7 ;
int n , m ;
vector<int> ke[100005];
bool visited[100005] ;
vector<int> tplt[200005];
int idx = 1 ;
void DFS(int u){
visited[u] = true ;
tplt[idx].push_back(u);
for(int v : ke[u]){
if(!visited[v]){
DFS(v);
}
}
}
void solve(){
cin >> n >> m ;
for(int i = 1 ; i <= m ; i++){
int x , y ; cin >> x >> y ;
ke[x].push_back(y);
ke[y].push_back(x);
}
for(int i = 1 ; i <= n ; i++){
if(!visited[i]){
DFS(i); // tim so thanh phan lien thong
++idx ;
}
}
for(int i = 1 ; i <= idx ; i++){
for(int x : tplt[i]){ // duyet tung phan tu cua tung tplt
if(tplt[i].size() - 1 != ke[x].size()){
cout << "NO" << endl;
return ;
}
}
}
cout << "YES" << endl;
}
int main() {
faster();
int test = 1 ;
// cin >> test ;
while(test--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZW5kbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgZmFzdGVyKCkgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyBjaW4udGllKG51bGxwdHIpOyBjb3V0LnRpZShudWxscHRyKTsKY29uc3QgaW50IE1PRCA9IDFlOSArIDcgOwoKaW50IG4gICwgbSA7CnZlY3RvcjxpbnQ+IGtlWzEwMDAwNV07CmJvb2wgdmlzaXRlZFsxMDAwMDVdIDsKdmVjdG9yPGludD4gdHBsdFsyMDAwMDVdOwppbnQgaWR4ID0gMSA7CnZvaWQgREZTKGludCB1KXsKICAgIHZpc2l0ZWRbdV0gPSB0cnVlIDsKICAgIHRwbHRbaWR4XS5wdXNoX2JhY2sodSk7CiAgICBmb3IoaW50IHYgOiBrZVt1XSl7CiAgICAgICAgaWYoIXZpc2l0ZWRbdl0pewogICAgICAgICAgICBERlModik7CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIHNvbHZlKCl7CiAgICBjaW4gPj4gbiA+PiBtIDsKICAgIGZvcihpbnQgaSA9IDEgOyBpIDw9IG0gOyBpKyspewogICAgICAgIGludCB4ICwgeSA7IGNpbiA+PiB4ID4+IHkgOwogICAgICAgIGtlW3hdLnB1c2hfYmFjayh5KTsKICAgICAgICBrZVt5XS5wdXNoX2JhY2soeCk7CiAgICB9CiAgICAKICAgIGZvcihpbnQgaSA9IDEgOyBpIDw9IG4gOyBpKyspewogICAgICAgIGlmKCF2aXNpdGVkW2ldKXsKICAgICAgICAgICAgREZTKGkpOyAvLyB0aW0gc28gdGhhbmggcGhhbiBsaWVuIHRob25nCiAgICAgICAgICAgICsraWR4IDsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGZvcihpbnQgaSA9IDEgOyBpIDw9IGlkeCA7IGkrKyl7CiAgICAgICAgZm9yKGludCB4IDogdHBsdFtpXSl7IC8vIGR1eWV0IHR1bmcgcGhhbiB0dSBjdWEgdHVuZyB0cGx0CiAgICAgICAgICAgIGlmKHRwbHRbaV0uc2l6ZSgpIC0gMSAhPSBrZVt4XS5zaXplKCkpewogICAgICAgICAgICAgICAgY291dCA8PCAiTk8iIDw8IGVuZGw7CiAgICAgICAgICAgICAgICByZXR1cm4gOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCAiWUVTIiA8PCBlbmRsOwoKfQoKaW50IG1haW4oKSB7CiAgICBmYXN0ZXIoKTsgCiAgICBpbnQgdGVzdCA9IDEgOyAKICAgIC8vIGNpbiA+PiB0ZXN0IDsKICAgIHdoaWxlKHRlc3QtLSkgICBzb2x2ZSgpOwogICAgcmV0dXJuIDA7Cn0KCgoKCgoK