#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  long long temp;
  while (b > 0) {
    temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}
vector<int> graph[4004];
int degree[4004];
bool adj[4004][4004];
int main() {
  int V, E, u, v, b, c, len;
  scanf("%d %d", &V, &E);
  for (int i = 0; i < E; i++) {
    scanf("%d %d", &u, &v);
    graph[u].push_back(v);
    graph[v].push_back(u);
    degree[u]++;
    degree[v]++;
    adj[u][v] = true;
    adj[v][u] = true;
  }
  int ans = INT_MAX;
  for (int a = 1; a <= V; a++) {
    len = graph[a].size();
    for (int i = 0; i < len; i++) {
      b = graph[a][i];
      for (int j = i + 1; j < len; j++) {
        c = graph[a][j];
        if (adj[b][c]) {
          ans = min(ans, degree[a] + degree[b] + degree[c] - 6);
        }
      }
    }
  }
  if (ans == INT_MAX) ans = -1;
  cout << ans << endl;
  return 0;
}
