#include <bits/stdc++.h>
using namespace std;
vector<int> g[4005];
bool vis[4001][4001];
int main() {
  ios_base::sync_with_stdio(false);
  long long s = INT_MAX, i, j, k, l, m, t, n, f = 0, z = 0;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> k >> l;
    g[k].push_back(l);
    vis[k][l] = true;
    g[l].push_back(k);
    vis[l][k] = true;
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < g[i].size(); j++) {
      m = g[i][j];
      for (k = 0; k < g[m].size(); k++) {
        l = g[m][k];
        if (vis[i][l]) {
          z = g[i].size() + g[m].size() + g[l].size() - 6;
          s = min(s, z);
        }
      }
    }
  }
  if (s != INT_MAX)
    cout << s << "\n";
  else
    cout << -1 << "\n";
  return 0;
}
