#include <bits/stdc++.h>
using namespace std;
int n, m, deg[4005], x, y;
bool f[4005][4005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    f[x][y] = f[y][x] = true;
    deg[x]++;
    deg[y]++;
  }
  int res = 1000000000;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (f[i][j]) {
        for (int k = j + 1; k <= n; k++) {
          if (f[i][k] && f[j][k]) {
            res = min(res, deg[i] + deg[j] + deg[k]);
          }
        }
      }
    }
  }
  (res == 1000000000) ? puts("-1") : printf("%d\n", res - 6);
  return 0;
}
