#include <bits/stdc++.h>
using namespace std;
int u[4050], v[4050], deg[4050];
bool a[4050][4050];
int sum = 0x7f7f7f7f;
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", u + i, v + i);
    a[u[i]][v[i]] = a[v[i]][u[i]] = true;
    deg[u[i]]++, deg[v[i]]++;
  }
  for (i = 0; i < m; i++)
    for (int j = 1; j <= n; j++) {
      if (j == u[i] || j == v[i]) continue;
      if (a[j][u[i]] && a[j][v[i]])
        sum = min(sum, deg[j] + deg[u[i]] + deg[v[i]] - 6);
    }
  printf("%d\n", sum == 0x7f7f7f7f ? -1 : sum);
  return 0;
}
