#include <bits/stdc++.h>
using namespace std;
set<int> add[4040];
vector<pair<int, int>> v;
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    add[x].insert(y);
    add[y].insert(x);
    v.push_back({x, y});
  }
  int ans = 1e7;
  for (auto i : v) {
    int x = i.first;
    int y = i.second;
    for (int j = 1; j <= n; j++) {
      if (add[x].count(j) && add[y].count(j)) {
        ans =
            min(ans, (int)(add[x].size() + add[y].size() + add[j].size() - 6));
      }
    }
  }
  if (ans == 1e7) ans = -1;
  cout << ans;
}
