#include <bits/stdc++.h>
using namespace std;
int n, m, in[4005][4005];
const int Inf = 1e+9;
int ans, x, y;
int s[4005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    in[x][y] = 1;
    in[y][x] = 1;
    s[x]++;
    s[y]++;
  }
  ans = Inf;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (in[i][j])
        for (int l = j + 1; l <= n; l++) {
          if (in[i][l] && in[j][l]) {
            ans = min(ans, s[i] + s[j] + s[l] - 6);
          }
        }
    }
  }
  if (ans == Inf) {
    cout << -1;
  } else
    cout << ans;
  return 0;
}
