#include <bits/stdc++.h>
using namespace std;
void imprimirVector(vector<int> v) {
  if (!v.empty()) {
    int p = v.size();
    cout << "[";
    for (int i = 0; i < (int)(p - 1); i++) cout << v[i] << ",";
    cout << v[p - 1] << "]" << endl;
  } else
    cout << "[]" << endl;
}
int toNumber(string s) {
  int Number;
  if (!(istringstream(s) >> Number)) Number = 0;
  return Number;
}
string toString(int number) {
  ostringstream ostr;
  ostr << number;
  return ostr.str();
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > ladj(n);
  vector<vector<bool> > adjm(n, vector<bool>(n));
  vector<long long> deg(n);
  long long minRecognition = 1000000000;
  for (int i = 0; i < (int)(m); i++) {
    long long a, b;
    cin >> a >> b;
    deg[a - 1]++;
    deg[b - 1]++;
    adjm[a - 1][b - 1] = true;
    adjm[b - 1][a - 1] = true;
    ladj[a - 1].push_back(b - 1);
    ladj[b - 1].push_back(a - 1);
  }
  for (int i = 0; i < (int)(n); i++) {
    vector<long long> vecinos = ladj[i];
    for (int j = 0; j < (int)(deg[i]); j++)
      for (int k = (j + 1); k < (int)(deg[i]); k++)
        if (adjm[vecinos[j]][vecinos[k]]) {
          minRecognition = min(minRecognition,
                               deg[i] + deg[vecinos[j]] + deg[vecinos[k]] - 6);
        }
  }
  if (minRecognition == 1000000000)
    cout << -1 << endl;
  else
    cout << minRecognition << endl;
  return 0;
}
