#include <bits/stdc++.h>
using namespace std;
long long deg[5005];
vector<long long> G[5005];
int main() {
  long long n, m;
  cin >> n >> m;
  long long matrix[n + 5][n + 5];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) matrix[i][j] = 0;
  for (int i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    deg[u]++, deg[v]++;
    matrix[u][v] = 1;
    matrix[v][u] = 1;
  }
  long long mn = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < G[i].size(); j++)
      for (int k = j + 1; k < G[i].size(); k++)
        if (matrix[G[i][j]][G[i][k]] == 1)
          if (mn == -1 or mn > (deg[i] + deg[G[i][j]] + deg[G[i][k]] - 6)) {
            mn = deg[i] + deg[G[i][j]] + deg[G[i][k]] - 6;
          }
  }
  cout << mn;
}
