#include <bits/stdc++.h>
using namespace std;
bool contains(vector<int> v, int x) {
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == x) return true;
  }
  return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > musketeers;
  for (int i = 0; i < n; i++) {
    vector<int> nm;
    musketeers.push_back(nm);
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    musketeers[x].push_back(y);
    musketeers[y].push_back(x);
  }
  int ans = -1;
  for (int c = 0; c < n; c++) {
    vector<int> m1 = musketeers[c];
    for (int j1 = 0; j1 < m1.size(); j1++) {
      vector<int> m2 = musketeers[m1[j1]];
      for (int j2 = 0; j2 < m2.size(); j2++) {
        vector<int> m3 = musketeers[m2[j2]];
        if (contains(m3, c)) {
          int val = (m1.size() - 2 + m2.size() - 2 + m3.size() - 2);
          if ((ans == -1) || (ans != -1 && val < ans)) {
            ans = val;
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}
