#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, a, b, mn = 100000, x, j, k, p, l;
  cin >> n >> m;
  int ara[n + 1];
  vector<vector<int> > v(n + 1);
  memset(ara, 0, sizeof ara);
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    ara[a]++;
    ara[b]++;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (i = 0; i < v.size(); i++) {
    if (!v[i].empty()) {
      for (j = 0; j < v[i].size(); j++) {
        p = v[i][j];
        for (k = j + 1; k < v[i].size(); k++) {
          if (!v[p].empty()) {
            for (l = 0; l < v[p].size(); l++) {
              if (v[i][k] == v[p][l] && ara[i] + ara[p] + ara[v[i][k]] < mn) {
                mn = ara[i] + ara[p] + ara[v[i][k]];
                x = mn - 6;
              }
            }
          }
        }
      }
    }
  }
  if (mn == 100000)
    cout << "-1";
  else
    cout << x;
  return 0;
}
