#include <bits/stdc++.h>
using namespace std;
vector<int> adjl[4009];
set<pair<int, int> > st;
int main() {
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
    st.insert(pair<int, int>(a, b));
    st.insert(pair<int, int>(b, a));
  }
  int ans = 9999999;
  for (int i = 1; i <= n; i++) {
    if (adjl[i].size() >= 2) {
      for (int j = 0; j < adjl[i].size(); j++) {
        for (int k = j + 1; k < adjl[i].size(); k++) {
          if (st.find(pair<int, int>(adjl[i][j], adjl[i][k])) != st.end()) {
            if (ans > adjl[i].size() + adjl[adjl[i][j]].size() +
                          adjl[adjl[i][k]].size() - 6)
              ans = adjl[i].size() + adjl[adjl[i][j]].size() +
                    adjl[adjl[i][k]].size() - 6;
          }
        }
      }
    }
  }
  if (ans == 9999999)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
