#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<int> adj[n + 1];
  unordered_set<int> checker[n + 1];
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    checker[u].insert(v);
    checker[v].insert(u);
  }
  int minvalue = INT_MAX;
  for (int i = 1; i <= n; i++) {
    int degree = adj[i].size();
    for (int j = 0; j < degree - 1; j++) {
      for (int k = j + 1; k < degree; k++) {
        int second = adj[i][j];
        int third = adj[i][k];
        if (checker[second].find(third) != checker[second].end()) {
          int sum = adj[i].size() - 2 + adj[second].size() - 2 +
                    adj[third].size() - 2;
          minvalue = min(minvalue, sum);
        }
      }
    }
  }
  if (minvalue == INT_MAX) minvalue = -1;
  cout << minvalue << "\n";
  return 0;
}
