#include <bits/stdc++.h>
using namespace std;
vector<set<int> > arr(4001);
int cal(int a, int b) {
  int c = INT_MAX;
  for (auto it = arr[a].begin(); it != arr[a].end(); ++it) {
    if (arr[b].find(*it) != arr[b].end() ? 1 : 0) {
      c = min(c, (int)arr[a].size() + (int)arr[b].size() +
                     (int)arr[*it].size() - 6);
    }
  }
  return c;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > sam;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    sam.push_back({x, y});
    arr[x].insert(y);
    arr[y].insert(x);
  }
  int mini = 1e9 + 1;
  for (int i = 0; i < m; ++i) {
    mini = min(cal(sam[i].first, sam[i].second), mini);
  }
  if (mini == 1e9 + 1) mini = -1;
  cout << mini << "\n";
}
