#include <bits/stdc++.h>
using namespace std;

const int N = (int) 5e4;
vector<int> graph[N];
vector<int> nice[N];
bool visited[N];
int depth[N], a[N], b[N];

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int m; cin >> m;
    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v; --u; --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
        a[i] = u; b[i] = v;
    }
    queue<int> q; visited[0] = true; q.push(0);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (auto v : graph[u]) if (!visited[v]) {
            visited[v] = true;
            depth[v] = depth[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < m; ++i) {
        if (depth[a[i]] == 1) nice[b[i]].push_back(a[i]);
        if (depth[b[i]] == 1) nice[a[i]].push_back(b[i]);
    }
    for (int i = 0; i < m; ++i) if (a[i] != 0 && b[i] != 0) {
        if (nice[a[i]].size() > 2 && nice[b[i]].size() > 2) {
            cout << "YES" << endl;
            return 0;
        }
        for (auto x : nice[a[i]]) if (x != b[i])
            for (auto y : nice[b[i]]) if (y != a[i] && x != y) {
                cout << "YES" << endl;
                return 0;
            }
    }
    cout << "NO" << endl;
    return 0;
}