#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  unordered_map<int, unordered_set<int> > dict;
  for (int i = 0; i < m; i++) {
    int src, dest;
    scanf("%d%d", &src, &dest);
    if (dict.find(src) == dict.end()) {
      unordered_set<int> newSet;
      newSet.insert(dest);
      dict[src] = newSet;
    } else {
      dict[src].insert(dest);
    }
    if (dict.find(dest) == dict.end()) {
      unordered_set<int> newSet;
      newSet.insert(src);
      dict[dest] = newSet;
    } else {
      dict[dest].insert(src);
    }
  }
  bool isFound = false;
  int count = 99999999;
  for (int i = 1; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (dict[i].find(j) == dict[i].end()) {
        continue;
      }
      int twoSize = dict[i].size() + dict[j].size();
      if (twoSize >= count) {
        continue;
      }
      for (int k = j + 1; k < n + 1; k++) {
        if (dict[i].find(k) != dict[i].end() &&
            dict[j].find(k) != dict[j].end()) {
          isFound = true;
          int threeSize = twoSize + dict[k].size();
          if (threeSize < count) {
            count = threeSize;
          }
        }
      }
    }
  }
  if (!isFound) {
    cout << "-1" << endl;
  } else {
    cout << count - 6 << endl;
  }
}
