#include <bits/stdc++.h>
int main() {
  int n, m, t1, t2, i, j, k, min = 10000, l;
  scanf("%d%d", &n, &m);
  char buffer[n][n];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) buffer[i][j] = 0;
  for (i = 0; i < m; i++) {
    scanf("%d%d", &t1, &t2);
    buffer[t1 - 1][t2 - 1] = 1;
    buffer[t2 - 1][t1 - 1] = 1;
  }
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (buffer[i][j] == 0) continue;
      for (k = j + 1; k < n; k++) {
        if (buffer[i][k] == 0) continue;
        if (buffer[j][k] == 0) continue;
        int temp = -6;
        for (l = 0; l < n; l++) {
          if (buffer[i][l] == 1) temp++;
          if (buffer[j][l] == 1) temp++;
          if (buffer[k][l] == 1) temp++;
        }
        if (temp < min) min = temp;
      }
    }
  }
  if (min == 10000)
    printf("-1");
  else
    printf("%d", min);
  return 0;
}
