#include <bits/stdc++.h>
using namespace std;
int N, M, Res = 4010 * 4010;
int Sum[4010];
int Mat[4010][4010];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    Mat[x][y] = Mat[y][x] = 1;
    ++Sum[x];
    ++Sum[y];
  }
  for (int i = 1; i <= N; ++i)
    for (int j = i + 1; j <= N; ++j)
      if (Mat[i][j]) {
        for (int k = j + 1; k <= N; ++k)
          if (Mat[i][k] && Mat[j][k]) Res = min(Res, Sum[i] + Sum[j] + Sum[k]);
      }
  printf("%d\n", Res == 4010 * 4010 ? -1 : Res - 6);
  return 0;
}
