#include <bits/stdc++.h>
using namespace std;
long long know[4005][4005];
vector<long long> adj[4005];
void solve() {
  long long n, test, i, l, d, ans = 1000000007;
  cin >> n >> test;
  map<long long, long long> m;
  memset(know, false, sizeof(know));
  while (test--) {
    cin >> l >> d;
    m[l]++;
    m[d]++;
    know[l][d] = true;
    know[d][l] = true;
  }
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = i + 1; j < n + 1; j++) {
      if (know[i][j]) {
        for (long long k = j + 1; k < n + 1; k++) {
          if (know[i][k] && know[j][k]) {
            l = m[i] + m[j] + m[k];
            if (l < ans) {
              ans = l;
            }
          }
        }
      }
    }
  }
  if (ans == 1000000007) {
    cout << -1;
    return;
  }
  cout << ans - 6;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
