#include <bits/stdc++.h>   using namespace std;   bitset<4001> g[4001];   int main() {     int n, m;     cin >> n >> m;     vector<pair<int, int> > v;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       g[a][b] = 1;       g[b][a] = 1;       v.push_back(pair<int, int>(a, b));     }     int minx = 100000000;     bool was = 0;     for (int i = 0; i < v.size(); i++) {       int a = v[i].first;       int b = v[i].second;       for (int j = 0; j < n; j++) {         if (g[a][j] && g[b][j]) {           minx = min(minx, (int)(g[a].count() + g[b].count() + g[j].count()) - 6);           was = true;         }       }     }     if (was)       cout << minx;     else       cout << -1;     return 0;   }   