#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4000 + 10;
const int INF = 0x3f3f3f3f;
int n, m;
bool go[MAXN][MAXN];
int edge[MAXN][2];
int du[MAXN];
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    go[u][v] = go[v][u] = true;
    edge[i][0] = u;
    edge[i][1] = v;
    du[u]++;
    du[v]++;
  }
  int ans = INF;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (go[i][edge[j][0]] && go[i][edge[j][1]])
        ans = min(ans, du[i] + du[edge[j][0]] + du[edge[j][1]] - 6);
    }
  }
  if (ans == INF)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
