#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const int MAXN = 4e3 + 10;
bool G[MAXN][MAXN];
struct Edge {
  int u, v;
} E[MAXN];
int cnt[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(G, 0, sizeof(G));
  memset(cnt, 0, sizeof(cnt));
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    G[u][v] = 1;
    G[v][u] = 1;
    E[i].u = u;
    E[i].v = v;
    cnt[u]++;
    cnt[v]++;
  }
  int ans = INF;
  for (int i = 1; i <= m; i++) {
    int u = E[i].u;
    int v = E[i].v;
    for (int k = 1; k <= n; k++) {
      if (k == u || k == v) continue;
      if (!G[u][k] || !G[v][k]) continue;
      ans = min(ans, cnt[u] + cnt[v] + cnt[k]);
    }
  }
  if (ans == INF) {
    puts("-1");
    return 0;
  }
  printf("%d\n", ans - 6);
  return 0;
}
