#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  vector<pair<int, int>> edges;
  set<int> adj[4001];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    edges.push_back({u, v});
    adj[u].insert(v);
    adj[v].insert(u);
  }
  int ans = -1;
  for (auto e : edges) {
    for (int i = 1; i <= n; i++) {
      if (e.first != i and e.second != i and adj[e.first].count(i) and
          adj[e.second].count(i)) {
        int cur =
            adj[e.first].size() + adj[e.second].size() + adj[i].size() - 6;
        ans = (ans == -1 ? cur : min(cur, ans));
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
