#include <bits/stdc++.h>
int aray[4003][4003];
int main() {
  int i, j, k, a, b, n, m, low = 1000000, sum = 0, proof = 0;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    aray[a][b] = 1;
    aray[b][a] = 1;
    aray[a][n + 1]++;
    aray[b][n + 1]++;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (aray[i][j] == 1) {
        for (k = j + 1; k <= n; k++) {
          if (aray[i][k] == 1 && aray[j][k] == 1) {
            sum = (aray[i][n + 1] - 2) + (aray[j][n + 1] - 2) +
                  (aray[k][n + 1] - 2);
            proof = 1;
            if (sum < low) {
              low = sum;
            }
          }
        }
      }
    }
  }
  if (proof == 0) {
    printf("-1");
  } else if (proof == 1) {
    printf("%d", low);
  }
  return 0;
}
