#include <bits/stdc++.h>
using namespace std;
long long n, m;
bool adj[4001][4001];
long long edge[4001][2];
long long degree[4001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  memset(adj, false, sizeof(adj));
  long long x, y;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    edge[i][0] = x;
    edge[i][1] = y;
    adj[x][y] = true;
    adj[y][x] = true;
  }
  memset(degree, 0, sizeof(degree));
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < n + 1; j++) {
      if (adj[i][j]) degree[i]++;
    }
  }
  long long ans = 2e9;
  for (long long i = 0; i < m; i++) {
    x = edge[i][0];
    y = edge[i][1];
    for (long long z = 1; z < n + 1; z++) {
      if (z != x && z != y && adj[x][z] && adj[y][z]) {
        ans = min(ans, degree[x] + degree[y] + degree[z] - 6);
      }
    }
  }
  if (ans != 2e9)
    cout << ans;
  else
    cout << -1;
  return 0;
}
