#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first < b.first;
}
long long exp(long long a, long long b) {
  long long ans = 1;
  while (b != 0) {
    if (b % 2) ans = ans * a;
    a = a * a;
    b /= 2;
  }
  return ans;
}
long long has[4005];
long long edge[4005][4005];
vector<long long> v[4005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = (long long)0; i < (long long)m; i++) {
    long long a, b;
    cin >> a >> b;
    has[a]++;
    has[b]++;
    edge[a][b] = 1;
    edge[b][a] = 1;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  long long ans = 100000000000LL;
  for (long long i = (long long)1; i < (long long)n + 1; i++) {
    for (long long j = (long long)i + 1; j < (long long)n + 1; j++) {
      if (edge[i][j]) {
        for (long long k = (long long)0; k < (long long)v[j].size(); k++) {
          long long ele = v[j][k];
          if (edge[i][ele]) {
            ans = min(ans, has[i] + has[j] + has[ele] - 6);
          }
        }
      }
    }
  }
  if (ans != 100000000000LL)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
