#include <bits/stdc++.h>
int main() {
  int i, j, k, n, m, sum = 40000, t = -1;
  scanf("%d %d", &n, &m);
  int a[n + 1][n + 1], x[m], y[m], b[n + 1];
  for (i = 0; i <= n; i++) b[i] = 0;
  for (i = 0; i < n + 1; i++) {
    for (j = 0; j < n + 1; j++) a[i][j] = 0;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    a[x[i]][y[i]]++;
    a[y[i]][x[i]]++;
    b[x[i]]++;
    b[y[i]]++;
  }
  for (i = 0; i < m; i++) {
    for (j = 1; j <= n; j++) {
      if (a[x[i]][j] > 0 && j != x[i] && a[y[i]][j] > 0) {
        if (b[x[i]] + b[j] + b[y[i]] < sum) {
          sum = b[x[i]] + b[j] + b[y[i]];
          t = 1;
        }
      }
    }
  }
  if (t == -1) sum = 5;
  printf("%d", sum - 6);
  return 0;
}
