#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 4050;
int n, m, d[maxn];
bool g[maxn][maxn];
int main() {
  int x, y;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    g[x][y] = g[y][x] = 1;
    d[x]++;
    d[y]++;
  }
  int ans = inf;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (g[i][j]) {
        for (int k = 1; k <= n; ++k) {
          if (g[i][k] && g[j][k]) {
            ans = min(ans, d[i] + d[j] + d[k]);
          }
        }
      }
    }
  }
  if (ans >= inf)
    puts("-1");
  else
    printf("%d\n", ans - 6);
  return 0;
}
