#include <bits/stdc++.h>
using namespace std;
int n, m, ans, d[4040], g[4040][4040];
int main() {
  int a, b;
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    d[a]++;
    d[b]++;
    g[a][b] = g[b][a] = 1;
  }
  ans = 0x3f3f3f3f;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (g[i][j] && d[i] >= 2 && d[j] >= 2 && d[i] + d[j] < ans) {
        for (int k = j + 1; k <= n; ++k) {
          if (g[i][k] && g[j][k]) ans = min(ans, d[i] + d[j] + d[k]);
        }
      }
    }
  }
  if (ans == 0x3f3f3f3f)
    printf("-1\n");
  else
    printf("%d\n", ans - 6);
  return 0;
}
