#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> s(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    s[x - 1].insert(y - 1);
    s[y - 1].insert(x - 1);
  }
  int result = -1;
  for (int i = 0; i < n; i++) {
    for (auto it2 = s[i].begin(); it2 != s[i].end(); it2++) {
      auto it3 = it2;
      it3++;
      int j = *it2;
      for (; it3 != s[i].end(); it3++) {
        int k = *it3;
        if (s[j].find(k) == s[j].end()) {
          continue;
        }
        int count =
            (int)s[i].size() + (int)s[j].size() + (int)s[k].size() - 2 * 3;
        if (result == -1 || count < result) {
          result = count;
        }
      }
    }
  }
  cout << result << endl;
  return 0;
}
