#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
int g[4005][4005];
int deg[4005];
int arr[4005][2];
int main() {
  int n, m;
  int x, y;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    arr[i][0] = x;
    arr[i][1] = y;
    g[x][y] = 1;
    g[y][x] = 1;
    deg[x]++;
    deg[y]++;
  }
  int e1, e2;
  int f1, f2;
  int ans = INT_MAX;
  for (int i = 0; i < m; i++) {
    e1 = arr[i][0];
    e2 = arr[i][1];
    for (int j = i + 1; j < m; j++) {
      f1 = arr[j][0];
      f2 = arr[j][1];
      if (e1 == f1) {
        if (g[e2][f2] == 1) {
          ans = min(ans, deg[e1] + deg[e2] + deg[f2] - 6);
        }
      } else if (e1 == f2) {
        if (g[e2][f1] == 1) ans = min(ans, deg[e1] + deg[e2] + deg[f1] - 6);
      } else if (e2 == f1) {
        if (g[e1][f2] == 1) ans = min(ans, deg[e1] + deg[e2] + deg[f2] - 6);
      } else if (e2 == f2) {
        if (g[e1][f1] == 1) ans = min(ans, deg[e1] + deg[e2] + deg[f1] - 6);
      }
    }
  }
  if (ans == INT_MAX)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
