#include <bits/stdc++.h>
using namespace std;
int adj[4005][4005] = {0};
int from[4005] = {0};
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > vec;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u][v] = adj[v][u] = 1;
    from[u]++;
    from[v]++;
    vec.push_back(make_pair(u, v));
  }
  int res = 10000000;
  for (int i = 0; i < vec.size(); i++) {
    int u = vec[i].first;
    int v = vec[i].second;
    for (int k = 0; k < n; k++) {
      if (adj[k][u] && adj[k][v]) {
        res = min(res, from[u] + from[k] + from[v] - 6);
      }
    }
  }
  if (res == 10000000)
    cout << -1 << endl;
  else
    cout << res << endl;
}
