#include <bits/stdc++.h>
using namespace std;
set<int> adj[4005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].insert(v);
    adj[v].insert(u);
  }
  int ans = -1;
  for (int i = 1; i <= n; i++)
    if (adj[i].size() >= 2) {
      for (auto it = adj[i].begin(); it != adj[i].end(); it++)
        if (adj[*it].size() >= 2) {
          int v = *it;
          for (auto it1 = adj[v].begin(); it1 != adj[v].end(); it1++)
            if (adj[i].find(*it1) != adj[i].end()) {
              if (ans == -1 ||
                  (adj[i].size() + adj[*it].size() + adj[*it1].size() - 6 <
                   ans))
                ans = (int)(adj[i].size() + adj[*it].size() + adj[*it1].size() -
                            6);
            }
        }
    }
  cout << ans << endl;
}
