import java.util.*;
class Graph {
public static void main
(String[] args
) { int n, m;
Scanner scanner
= new Scanner
(System.
in); n = scanner.nextInt();
m = scanner.nextInt();
for (int i = 0; i < n; i++) {
gr[i] = new ArrayList<>();
}
int s = 0;
for (int i = 0; i < m; i++) {
int u, v;
u = scanner.nextInt();
v = scanner.nextInt();
gr[u - 1].add(v - 1);
gr[v - 1].add(u - 1);
}
LinkedList<Integer> queue = new LinkedList<>();
queue.push(s);
boolean used[] = new boolean[n];
used[s] = true;
while (!queue.isEmpty()) {
int v = queue.peek();
queue.pop();
for (int i = 0; i < gr[v].size(); ++i) {
int to = gr[v].get(i);
if (!used[to]) {
used[to] = true;
queue.push(to);
}
}
}
for (int i = 0; i < used.length; i++) {
if (used[i] == false) {
answer = "NO";
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgR3JhcGggewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIGludCBuLCBtOwogICAgICAgIFNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgbiA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgIG0gPSBzY2FubmVyLm5leHRJbnQoKTsKCiAgICAgICAgQXJyYXlMaXN0PEludGVnZXI+IGdyW10gPSBuZXcgQXJyYXlMaXN0W25dOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgIGdyW2ldID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgfQoKICAgICAgICBpbnQgcyA9IDA7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBtOyBpKyspIHsKICAgICAgICAgICAgaW50IHUsIHY7CiAgICAgICAgICAgIHUgPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgICAgdiA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgICAgICBnclt1IC0gMV0uYWRkKHYgLSAxKTsKICAgICAgICAgICAgZ3JbdiAtIDFdLmFkZCh1IC0gMSk7CiAgICAgICAgfQoKICAgICAgICBMaW5rZWRMaXN0PEludGVnZXI+IHF1ZXVlID0gbmV3IExpbmtlZExpc3Q8PigpOwogICAgICAgIHF1ZXVlLnB1c2gocyk7CiAgICAgICAgYm9vbGVhbiB1c2VkW10gPSBuZXcgYm9vbGVhbltuXTsKICAgICAgICB1c2VkW3NdID0gdHJ1ZTsKCiAgICAgICAgd2hpbGUgKCFxdWV1ZS5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgaW50IHYgPSBxdWV1ZS5wZWVrKCk7CiAgICAgICAgICAgIHF1ZXVlLnBvcCgpOwogICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGdyW3ZdLnNpemUoKTsgKytpKSB7CiAgICAgICAgICAgICAgICBpbnQgdG8gPSBnclt2XS5nZXQoaSk7CiAgICAgICAgICAgICAgICBpZiAoIXVzZWRbdG9dKSB7CiAgICAgICAgICAgICAgICAgICAgdXNlZFt0b10gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHF1ZXVlLnB1c2godG8pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIFN0cmluZyBhbnN3ZXIgPSAiWUVTIjsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IHVzZWQubGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgaWYgKHVzZWRbaV0gPT0gZmFsc2UpIHsKICAgICAgICAgICAgICAgIGFuc3dlciA9ICJOTyI7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKGFuc3dlcik7CiAgICB9Cn0K