#include <bits/stdc++.h>
int n, m, result = INT_MAX;
std::vector<int> v[4005];
int main() {
  std::cin >> n >> m;
  for (int i = 0, x, y; i < m; ++i) {
    std::cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= n; ++i) {
    for (int x : v[i]) {
      if (x == i) continue;
      for (int y : v[x]) {
        if (std::find(v[y].begin(), v[y].end(), i) != v[y].end()) {
          result = std::min(result,
                            int(v[i].size() + v[x].size() + v[y].size() - 6));
        }
      }
    }
  }
  std::cout << (result != INT_MAX ? result : -1);
}
