#include <bits/stdc++.h>
using namespace std;
const int MAX = 4e5 + 5;
int vis[MAX];
vector<int> adj[MAX];
vector<vector<int> > trip;
void dfs(int x) {
  vis[x] = 1;
  for (auto u : adj[x]) {
    if (!vis[u]) {
      for (auto v1 : adj[x]) {
        for (auto v2 : adj[u]) {
          if (!vis[v1] && !vis[v2] && v1 == v2) {
            vector<int> triplet;
            triplet.push_back(x);
            triplet.push_back(u);
            triplet.push_back(v1);
            trip.push_back(triplet);
          }
        }
      }
    }
  }
}
int main() {
  int n, m, x, y, minm = 1e9 + 9;
  cin >> n >> m;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) dfs(i);
  }
  for (auto v : trip) {
    minm = min(minm, (int)(adj[v[0]].size() + adj[v[1]].size() +
                           adj[v[2]].size() - 6));
  }
  if (!trip.empty())
    cout << minm << endl;
  else
    cout << -1 << endl;
}
