// Arup Guha
// 6/3/2026
// Solution to COP 3502 Recitation Problem #2: Kattis Problem: Sky Islands
// https://open.kattis.com/problems/skyislands

using namespace std;
#include <bits/stdc++.h>

void go(vector<vector<int>>& g, vector<bool>& visited, int loc);

int main() {

    // Get # vertices, edges.
    int n, numE;
    cin >> n >> numE;

    // Set up an empty graph.
    vector<vector<int>> g(n);

    // Read in each edge.
    for (int i=0; i<numE; i++) {

        // Do 0 based.
        int u, v;
        scanf("%d%d", &u, &v);
        u--;
        v--;

        // Mark both ways.
        g[u].push_back(v);
        g[v].push_back(u);
    }

    // Will mark where we've visited.
    vector<bool> visited(n, false);

    // Run our DFS!
    go(g, visited, 0);

    // If anyone's not visited, change the result to false.
    bool res = true;
    for (int i=0; i<n; i++)
        if (!visited[i])
            res = false;

    // Ta da!
    if (res)    printf("YES\n");
    else        printf("NO\n");

    return 0;
}

// Runs a DFS from loc in the graph g, marking visited locations in visited.
void go(vector<vector<int>>& g, vector<bool>& visited, int loc) {

    // Mark it.
    visited[loc] = true;

    for (auto x=g[loc].begin(); x != g[loc].end(); x++) {

        // Been here before.
        if (visited[*x]) continue;

        // We can go to this new neighbor, *x...
        go(g, visited, *x);
    }
}
