#include <bits/stdc++.h>
using namespace std;
int inf = 1000000001;
long long int mod = 1000000007;
int dx[] = {1, 1, -1, -1};
int dy[] = {1, -1, 1, -1};
vector<bool> isprime;
vector<int> primes;
void seive(int n, bool wantlist = true) {
  isprime.resize(n + 1);
  isprime[0] = isprime[1] = false;
  int sq = sqrt(n + 1);
  for (int i = 2; i < sq + 1; i++) {
    if (isprime[i]) {
      for (int j = i * i; j <= n; j += i) isprime[j] = false;
    }
  }
  for (int i = 2; wantlist && i <= n; i++) {
    if (isprime[i]) primes.push_back(i);
  }
}
template <class T>
inline T gcd(T a, T b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
inline long long int bexp(long long int x, long long int n) {
  long long int res = 1;
  x %= mod;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d", &n);
  ;
  scanf("%d", &m);
  ;
  vector<set<int> > ed(n);
  vector<int> rec(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d", &u);
    ;
    scanf("%d", &v);
    ;
    u--;
    v--;
    rec[u]++;
    rec[v]++;
    ed[u].insert(v);
    ed[v].insert(u);
  }
  int ans = inf;
  for (int i = 0; i < n; i++) {
    for (int j : ed[i]) {
      for (int k = 0; k < n; k++) {
        if (ed[i].find(k) != ed[i].end() && ed[j].find(k) != ed[j].end()) {
          ans = min(ans, rec[i] + rec[j] + rec[k] - 6);
        }
      }
    }
  }
  if (ans == inf)
    cout << "-1" << endl;
  else
    cout << ans << endl;
}
