#include <bits/stdc++.h>
using namespace std;
bool fld[4001][4001];
int degree[4001];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) degree[i] = 0;
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    degree[a - 1]++;
    degree[b - 1]++;
    fld[a - 1][b - 1] = true;
    fld[b - 1][a - 1] = true;
  }
  int best = 1e9;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (fld[i][j]) {
        for (int k = j + 1; k < N; k++) {
          if (fld[i][k] && fld[j][k])
            best = min(best, degree[i] + degree[j] + degree[k]);
        }
      }
    }
  }
  if (best == 1e9)
    cout << -1;
  else
    cout << best - 6;
  return 0;
}
