#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int number, edge;
  int p1, p2;
  int coupleValue1[4005];
  int coupleValue2[4005];
  int store[4005] = {0};
  cin >> number >> edge;
  vector<vector<int> > vec(4005, vector<int>(4005));
  for (int i = 0; i < edge; i++) {
    cin >> p1 >> p2;
    vec[p1][p2] = 2;
    store[p1]++;
    store[p2]++;
    coupleValue1[i] = p1;
    coupleValue2[i] = p2;
  }
  unsigned long long result = 500000000000;
  unsigned long long countt;
  int a, b;
  for (int i = 0; i < edge; i++) {
    a = coupleValue1[i];
    b = coupleValue2[i];
    for (int j = 0; j < number; j++) {
      if ((vec[a][j] == 2 || vec[j][a] == 2) &&
          (vec[b][j] == 2 || vec[j][b] == 2)) {
        countt = (store[a] + store[b] + store[j]) - 6;
        if (countt < result) {
          result = countt;
        }
      }
    }
  }
  if (result == 500000000000) {
    cout << "-1" << endl;
  } else {
    cout << result << endl;
  }
  return 0;
}
