#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > G(n);
  set<pair<int, int> > S;
  vector<pair<int, int> > pairs(m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    pairs[i] = make_pair(a, b);
    G[a].push_back(b);
    G[b].push_back(a);
    S.insert(make_pair(a, b));
    S.insert(make_pair(b, a));
  }
  int ans = INF;
  for (int edge = 0; edge < m; ++edge) {
    for (int vertex = 0; vertex < n; ++vertex) {
      if (vertex != pairs[edge].first && vertex != pairs[edge].second) {
        if (S.find(make_pair(vertex, pairs[edge].first)) != S.end() &&
            S.find(make_pair(vertex, pairs[edge].second)) != S.end()) {
          ans = min(ans, (int)G[vertex].size() +
                             (int)G[pairs[edge].first].size() +
                             (int)G[pairs[edge].second].size() - 6);
        }
      }
    }
  }
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
