#include <bits/stdc++.h>
using namespace std;
const int maxn = 4500;
const int inf = 0x3f3f3f3f;
bool mat[maxn][maxn] = {0};
int u[maxn], v[maxn];
int deg[maxn] = {0};
inline int min(int a, int b) { return a < b ? a : b; }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> u[i] >> v[i];
    deg[u[i]]++;
    deg[v[i]]++;
    mat[u[i]][v[i]] = mat[v[i]][u[i]] = 1;
  }
  int ans = inf;
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (mat[u[i]][j] && mat[j][v[i]]) {
        ans = min(ans, deg[u[i]] + deg[v[i]] + deg[j]);
      }
    }
  }
  if (ans != inf)
    cout << ans - 6 << endl;
  else
    puts("-1");
}
