#include <bits/stdc++.h>
using namespace std;
const int CMax = 4002;
int n, m, sk, sk1, u, v, ats = CMax * 3, sum;
vector<int> K[CMax];
bool Mx[CMax][CMax];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &sk, &sk1);
    K[sk].push_back(sk1);
    K[sk1].push_back(sk);
    Mx[sk][sk1] = true;
    Mx[sk1][sk] = true;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < K[i].size(); j++) {
      u = K[i][j];
      for (int l = 0; l < K[u].size(); l++) {
        v = K[u][l];
        if (Mx[i][v]) {
          sum = K[i].size() + K[u].size() + K[v].size() - 6;
          if (sum < ats) ats = sum;
        }
      }
    }
  }
  if (ats == CMax * 3) {
    printf("-1\n");
  } else {
    printf("%d\n", ats);
  }
}
