#include <bits/stdc++.h>
int n, m, a, b, du[4010], mat[4010][4010];
bool used[4010], mm[4010][4010];
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    mat[a][++mat[a][0]] = b;
    mat[b][++mat[b][0]] = a;
    mm[a][b] = 1;
    mm[b][a] = 1;
    du[a]++;
    du[b]++;
  }
  int v1, v2, min_du = 999999;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= mat[i][0]; j++) {
      v1 = i;
      v2 = mat[i][j];
      for (int k = 1; k <= n; k++) {
        if (k == v1 || k == v2) continue;
        if (mm[k][v1] && mm[k][v2])
          if (du[v1] + du[v2] + du[k] - 6 < min_du) {
            min_du = du[v1] + du[v2] + du[k] - 6;
          }
      }
    }
  }
  if (min_du != 999999)
    printf("%d", min_du);
  else
    printf("-1");
  return 0;
}
