#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000007;
const long long INFL = 1e15;
void printv(vector<int> a) {
  for (int i = 0; i < (int)a.size(); i++) {
    cout << a[i] << ' ';
  }
  cout << endl;
}
void prints(set<pair<long long, long long>> s) {
  for (set<pair<long long, long long>>::iterator it = s.begin(); it != s.end();
       it++) {
    cout << -(*it).first << " ";
  }
  cout << endl;
}
long long fact_pow(long long n, long long k) {
  long long res = 0;
  while (n) {
    n /= k;
    res += n;
  }
  return res;
}
vector<int> allprime(long long n) {
  vector<char> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i <= n; ++i)
    if (prime[i])
      if (i * 1ll * i <= n)
        for (int j = i * i; j <= n; j += i) prime[j] = false;
  vector<int> ans;
  for (int i = 2; i < n + 1; i++) {
    if (prime[i]) ans.push_back(i);
  }
  return ans;
}
int binpow(int a, int n, int m = 1e9 + 7) {
  if (n == 0) return 1;
  if (n % 2 == 1)
    return (binpow(a, n - 1, m) % m * a) % m;
  else {
    long long b = binpow(a, n / 2, m);
    return (b * b) % m;
  }
}
bool isprime(long long p) {
  if (p == 1) return false;
  if (p % 2 == 0) {
    return p == 2;
  }
  for (int i = 3; i * i <= p; i += 2) {
    if (p % i == 0) return false;
  }
  return true;
}
vector<int> factorization(int n) {
  vector<int> a;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      a.push_back(i);
    }
  }
  unsigned long long y = a.size();
  for (unsigned long long i = y - 1; i > -1; i--) {
    if (a[i] * a[i] != n) {
      a.push_back(n / a[i]);
    }
  }
  return a;
}
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long max(vector<long long> a) {
  long long x = a[0];
  for (int i = 0; i < a.size(); i++) {
    x = max(x, a[i]);
  }
  return x;
}
int min(vector<int> a) {
  int x = a[0];
  for (int i = 0; i < a.size(); i++) {
    x = min(x, a[i]);
  }
  return x;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
int Solve() {
  int n, m;
  cin >> n >> m;
  vector<set<long long>> v(n);
  vector<pair<int, int>> p(m);
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    v[a].insert(b);
    v[b].insert(a);
    p[i] = {a, b};
  }
  int ans = INF;
  for (int i = 0; i < m; i++) {
    a = p[i].first;
    b = p[i].second;
    for (int j = 0; j < n; j++) {
      if (v[a].count(j) and v[b].count(j)) {
        ans = min(ans, v[a].size() + v[b].size() + v[j].size() - 6);
      }
    }
  }
  if (ans == INF)
    cout << -1;
  else
    cout << ans;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TestS = 1;
  while (TestS--) {
    Solve();
    cout << endl;
  }
  return 0;
}
