#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
bool adj[4010][4010];
int n, m, u, v, cnt[4010];
vector<vector<int> > node;
int main() {
  scanf("%d%d", &n, &m);
  node.resize(n + 1);
  while (m--) {
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
    node[v].push_back(u);
    adj[u][v] = adj[v][u] = true;
  }
  for (int i = 1; i <= n; ++i) cnt[i] = node[i].size();
  int sol = INF;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (!adj[i][j]) continue;
      for (int a = 0; a < node[i].size(); ++a) {
        int k = node[i][a];
        if (!adj[k][j]) continue;
        sol = min(sol, cnt[i] + cnt[j] + cnt[k] - 6);
      }
    }
  }
  printf("%d\n", sol == INF ? -1 : sol);
}
