#include <bits/stdc++.h>
using namespace std;
bool edj[4002][4002] = {false};
int main() {
  int n, m, i, j, u[4002], v[4002], deg[4002] = {0};
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> u[i] >> v[i];
    edj[u[i]][v[i]] = edj[v[i]][u[i]] = true;
    deg[u[i]]++;
    deg[v[i]]++;
  }
  int ans = -1;
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (j == u[i] || j == v[i]) continue;
      if (!edj[u[i]][j] || !edj[v[i]][j]) continue;
      if (ans == -1) ans = deg[u[i]] + deg[v[i]] + deg[j];
      ans = min(ans, deg[u[i]] + deg[v[i]] + deg[j]);
    }
  }
  if (ans != -1) ans = ans - 6;
  cout << ans << "\n";
  return 0;
}
