#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
long long powmod(long long a, long long b, long long mod) {
  if (b == 0 || a == 1) {
    if (mod == 1)
      return 0;
    else
      return 1;
  }
  if (b % 2 == 0) {
    long long k = powmod(a, b / 2, mod);
    return (k * k) % mod;
  } else {
    long long k = powmod(a, b / 2, mod);
    return ((k * k) % mod * a) % mod;
  }
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a > b)
    return gcd(a % b, b);
  else
    return gcd(b % a, a);
}
int prime(int p) {
  for (int i = 2; i * i <= p; i++) {
    if (p % i == 0 && i < p) return i;
  }
  return 1;
}
int inv(int a, int mod) { return powmod(a, mod - 2, mod); }
int random_modul() {
  uniform_int_distribution<int> u1(1e9, 2e9);
  int pepega = u1(rnd);
  while (prime(pepega) != 1) pepega = u1(rnd);
  return pepega;
}
int mod;
void solve() {
  int a, b;
  cin >> a >> b;
  vector<pair<int, int>> m(b);
  int min1 = 10000000;
  vector<int> deg(a);
  map<pair<short int, short int>, bool> find;
  for (int i = 0; i < b; i++) {
    cin >> m[i].first >> m[i].second;
    m[i].first--;
    m[i].second--;
    find[{min(m[i].first, m[i].second), max(m[i].first, m[i].second)}] = 1;
    deg[m[i].first]++;
    deg[m[i].second]++;
  }
  for (int i = 0; i + 1 < b; i++) {
    for (int j = i + 1; j < b; j++) {
      if (m[i].first == m[j].first) {
        if (find[{min(m[i].second, m[j].second),
                  max(m[i].second, m[j].second)}]) {
          min1 =
              min(min1, deg[m[i].first] + deg[m[i].second] + deg[m[j].second]);
        }
      }
      if (m[i].first == m[j].second) {
        if (find[{min(m[i].second, m[j].first),
                  max(m[i].second, m[j].first)}]) {
          min1 =
              min(min1, deg[m[i].first] + deg[m[i].second] + deg[m[j].first]);
        }
      }
      if (m[i].second == m[j].first) {
        if (find[{min(m[i].first, m[j].second),
                  max(m[i].first, m[j].second)}]) {
          min1 =
              min(min1, deg[m[i].second] + deg[m[i].first] + deg[m[j].second]);
        }
      }
      if (m[i].second == m[j].second) {
        if (find[{min(m[i].first, m[j].first), max(m[i].first, m[j].first)}]) {
          min1 =
              min(min1, deg[m[i].first] + deg[m[i].second] + deg[m[j].first]);
        }
      }
    }
  }
  if (min1 != 10000000)
    cout << min1 - 6;
  else
    cout << -1;
  return;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tututu;
  tututu = 1;
  mod = random_modul();
  for (int qwerty = 0; qwerty < tututu; qwerty++) solve();
  return 0;
}
