#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  bool present[n][n];
  for (int i = 0; i < n; i++) fill_n(present[i], n, false);
  map<int, int> weight;
  vector<pair<int, int> > data;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    r--;
    l--;
    present[l][r] = true;
    present[r][l] = true;
    weight[l]++;
    weight[r]++;
    data.push_back({l, r});
    data.push_back({r, l});
  }
  sort(data.begin(), data.end());
  int res = INT_MAX;
  int left = 0;
  int right = 1;
  while (left < data.size()) {
    while (right < data.size() && data[right].first == data[left].first)
      right++;
    for (int i = left; i < right; i++) {
      for (int j = left; j < right; j++) {
        if (i != j && present[data[i].second][data[j].second]) {
          int total = weight[data[i].first] + weight[data[i].second] +
                      weight[data[j].second];
          res = min(res, total - 6);
        }
      }
    }
    left = right;
    right++;
  }
  cout << (res == INT_MAX ? -1 : res) << "\n";
  return 0;
}
