#include <bits/stdc++.h>
using namespace std;
vector<int> adj[4010];
int n, m, i, j, k, u, v, w, from, res, to, arr[4010][4010], sz[4010];
int main() {
  scanf(" %d %d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf(" %d %d", &from, &to);
    adj[from].push_back(to);
    adj[to].push_back(from);
    arr[from][to] = arr[to][from] = 1;
  }
  for (i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
    sz[i] = adj[i].size();
  }
  res = 100000010;
  for (i = 1; i <= n; i++) {
    u = i;
    for (j = 0; j < sz[i]; j++) {
      v = adj[i][j];
      for (k = 0; k < sz[v]; k++) {
        w = adj[v][k];
        if (arr[u][v] == 1 && arr[v][w] == 1 && arr[u][w] == 1 && u != v &&
            v != w) {
          res = min(res, sz[u] + sz[v] + sz[w] - 6);
        }
      }
    }
  }
  if (res >= 100000010)
    printf("-1\n");
  else
    printf("%d\n", res);
  return 0;
}
