#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
vector<int> g[4005];
int main() {
  int n, m;
  cin >> n >> m;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v, --u, --v;
    g[u].push_back(v), g[v].push_back(u);
  }
  int ans = 5000;
  for (int a = 0; a < n; a++)
    for (int b : g[a])
      for (int c : g[b])
        if (find(g[a].begin(), g[a].end(), c) != g[a].end())
          ans = min(ans, ((int)g[a].size() + (int)g[b].size() +
                          (int)g[c].size() - 6));
  if (ans == 5000) ans = -1;
  cout << ans << '\n';
  return 0;
}
