#include <bits/stdc++.h>
using namespace std;
bool dp[4005][4005];
int p[4005];
int main() {
  int n, m, a, b, c, i, x, y, ans;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    dp[x][y] = dp[y][x] = true;
    p[x]++;
    p[y]++;
  }
  ans = 1e9;
  for (a = 1; a <= n; a++) {
    if (p[a] < 2) continue;
    for (b = a + 1; b <= n; b++) {
      if (p[b] < 2 || !dp[a][b]) continue;
      for (c = b + 1; c <= n; c++) {
        if (p[c] < 2 || !dp[a][c] || !dp[b][c]) continue;
        int s = p[a] + p[b] + p[c] - 6;
        ans = min(ans, s);
      }
    }
  }
  cout << (ans == 1e9 ? -1 : ans);
  return 0;
}
