#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long maxn = 1e5 + 5;
long long N;
void solve() {
  long long M;
  cin >> N >> M;
  long long a, b;
  vector<vector<long long>> adj(N, vector<long long>(N));
  vector<long long> outs(N);
  for (long long i = 0; i < M; i++) {
    cin >> a >> b;
    a--;
    b--;
    adj[a][b] = 1;
    adj[b][a] = 1;
    outs[a]++, outs[b]++;
  }
  long long ans = INT16_MAX;
  bool f = 0;
  for (long long i = 0; i < N; i++) {
    for (long long j = i + 1; j < N; j++) {
      if (adj[i][j] == 1) {
        for (long long k = 0; k < N; k++) {
          if (adj[i][k] == 1 and adj[j][k] == 1) {
            f = 1;
            ans = min(ans, outs[i] + outs[j] + outs[k] - 6);
          }
        }
      }
    }
  }
  if (f == 0) {
    cout << -1;
    return;
  }
  cout << ans;
}
signed main() {
  long long t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
