#include <bits/stdc++.h>
using namespace std;
const int INF = 0xfffffff;
const int MAX = 4001;
vector<int> G[MAX];
bool ok[MAX][MAX];
int main() {
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    ok[u][v] = ok[v][u] = true;
  }
  unsigned int sum = INF;
  for (int i = 1; i <= n; ++i) {
    int me = G[i].size();
    for (int j = 0; j < (int)G[i].size(); ++j) {
      int she = G[G[i][j]].size();
      for (int k = j + 1; k < (int)G[i].size(); ++k) {
        if (ok[G[i][j]][G[i][k]]) {
          if (sum > me + she + G[G[i][k]].size() - 6) {
            sum = me + she + G[G[i][k]].size() - 6;
          }
        }
      }
    }
  }
  if (sum == INF) {
    cout << "-1" << endl;
  } else {
    cout << sum << endl;
  }
  return 0;
}
