#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int> > g(n + 1);
  map<int, int> co;
  for (int i = 0; i < m; i++) {
    int n1, n2;
    cin >> n1 >> n2;
    g[n1].insert(n2);
    g[n2].insert(n1);
    co[n1]++;
    co[n2]++;
  }
  int minn = 1000000000;
  for (int i = 1; i <= n; i++) {
    set<int>::iterator iter;
    for (iter = g[i].begin(); iter != g[i].end(); iter++) {
      set<int>::iterator iter2;
      for (iter2 = g[*iter].begin(); iter2 != g[*iter].end(); iter2++) {
        if (*iter2 == i) continue;
        if (g[*iter2].count(i)) {
          minn = min(minn, co[*iter] + co[*iter2] + co[i] - 6);
        }
      }
    }
  }
  if (minn == 1000000000)
    cout << -1 << endl;
  else
    cout << minn << endl;
  return 0;
}
