#include <bits/stdc++.h>
using namespace std;
long long int tc, cnt = 0, number, many, total = 0;
int rmove[4] = {0, 0, -1, 1};
int cmove[4] = {1, -1, 0, 0};
long long int power(long long int x, long long int y, long long int mod) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return (power(x, y / 2, mod) % mod * power(x, y / 2, mod) % mod) % mod;
  else
    return x * (power(x, y / 2, mod) % mod * power(x, y / 2, mod) % mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> many >> number;
  vector<set<int> > adjList;
  adjList.resize(many);
  for (int i = 0; i < number; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adjList[a].insert(b);
    adjList[b].insert(a);
  }
  int answer = 1e9;
  for (int i = 0; i < many; i++) {
    for (auto j : adjList[i]) {
      if (j == i) continue;
      for (auto k : adjList[j]) {
        if (j == k || k == i || !adjList[k].count(i)) continue;
        int sum = adjList[i].size() + adjList[j].size() + adjList[k].size();
        if (adjList[i].count(j)) sum--;
        if (adjList[j].count(i)) sum--;
        if (adjList[i].count(k)) sum--;
        if (adjList[j].count(k)) sum--;
        if (adjList[k].count(i)) sum--;
        if (adjList[k].count(j)) sum--;
        answer = min(answer, sum);
      }
    }
  }
  if (answer == 1e9) answer = -1;
  cout << answer << endl;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
