#include <bits/stdc++.h>
using namespace std;
const int Max = 1e7 + 7;
int n, m;
int e[5000][5000];
int a[5000], b[5000];
int vis[5000];
int main() {
  ios::sync_with_stdio(0);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x][y] = e[y][x] = 1;
    vis[x]++, vis[y]++;
    a[i] = x, b[i] = y;
  }
  int ans = 0x3f3f3f3f;
  for (int i = 1; i <= m; i++) {
    int x = a[i], y = b[i];
    for (int j = 1; j <= n; j++) {
      if (j == x || j == y) continue;
      if (e[j][x] == 1 && e[j][y] == 1) {
        ans = min(ans, vis[x] + vis[y] + vis[j]);
      }
    }
  }
  if (ans == 0x3f3f3f3f)
    printf("-1\n");
  else
    printf("%d\n", ans - 6);
  return 0;
}
