#include <bits/stdc++.h>
using namespace std;
int w[4005][4005], e[2][4005];
int c[4005], min1 = 1e9, min2 = 1e9;
int main() {
  int n, m, i, x, y, sum, j;
  int f = 0;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    c[x]++;
    c[y]++;
    w[x][y] = 1;
    w[y][x] = 1;
    e[0][i] = x;
    e[1][i] = y;
  }
  for (i = 0; i < m; i++) {
    sum = 0;
    min2 = 1e9;
    x = e[0][i];
    y = e[1][i];
    sum += c[x] + c[y];
    for (j = 1; j <= n; j++) {
      if (j == x || j == y) continue;
      if (w[j][x] == 1 || w[x][j] == 1)
        if (w[j][y] == 1 || w[y][j] == 1) {
          f = 1;
          if (min2 > sum + c[j]) min2 = sum + c[j];
        }
    }
    if (min1 > min2) min1 = min2;
  }
  if (min1 != 1e9)
    cout << min1 - 6;
  else
    cout << -1;
  return 0;
}
