#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 5;
int degree[mx];
int graph[4005][4005];
int a[mx];
int b[mx];
int32_t main() {
  int n, m;
  cin >> n >> m;
  memset(degree, 0, sizeof(degree));
  memset(graph, 0, sizeof(graph));
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    degree[a[i]]++;
    degree[b[i]]++;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
  }
  int ans = INT_MAX;
  for (int i = 0; i < m; i++) {
    int x = a[i];
    int y = b[i];
    for (int j = 1; j < n + 1; j++) {
      if (j != x && j != y) {
        if (graph[x][j] == 1 && graph[y][j] == 1) {
          ans = min(degree[x] + degree[y] + degree[j] - 6, ans);
        }
      }
    }
  }
  if (ans != INT_MAX) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
