#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> e[4005];
bool mp[4005][4005];
int du[4005];
int ans;
int main() {
  int i, j, k;
  while (cin >> n >> m) {
    memset(mp, false, sizeof mp);
    memset(du, 0, sizeof du);
    for (i = 0; i <= 4000; i++) e[i].clear();
    for (i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      mp[u][v] = mp[v][u] = true;
      du[u]++;
      du[v]++;
      e[u].push_back(v);
      e[v].push_back(u);
    }
    ans = 0x3FFFFFFF;
    for (i = 1; i <= n; i++) {
      int len = e[i].size();
      for (j = 0; j < len; j++) {
        int en1 = e[i][j];
        int sz = e[en1].size();
        for (k = 0; k < sz; k++) {
          int en2 = e[en1][k];
          if (mp[en2][i] && i != en1 && en1 != en2 && i != en2) {
            int dd = du[i] + du[en1] + du[en2] - 6;
            ans = min(ans, dd);
          }
        }
      }
    }
    if (ans == 0x3FFFFFFF)
      cout << -1 << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
