#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long powm(long long base, long long exp, long long mod = 1000000007) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return ans;
}
long long adj[4005][4005], deg[4005];
int main() {
  long long n, m, minm = 1000111000111000111LL, u, v;
  cin >> n >> m;
  for (long long i = 1; i < m + 1; i++) {
    cin >> u >> v;
    if (u > v) swap(u, v);
    adj[u][v] = 1, deg[u]++, deg[v]++;
  }
  for (long long i = 1; i < n + 1; i++)
    for (long long j = i + 1; j < n + 1; j++)
      if (adj[i][j])
        for (long long k = j + 1; k < n + 1; k++)
          if (adj[i][k] and adj[j][k])
            minm = min(minm, deg[i] + deg[j] + deg[k]);
  cout << (minm == 1000111000111000111LL ? -1 : minm - 6);
  return 0;
}
