#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxn = 4e3 + 2;
int know[maxn];
bool a[maxn][maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    a[u][v] = a[v][u] = true;
    know[u]++;
    know[v]++;
  }
  int res = 1e9;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (a[i][j]) {
        for (int k = j + 1; k <= n; ++k) {
          if (a[i][k] && a[j][k]) {
            res = min(res, know[i] + know[j] + know[k]);
          }
        }
      }
    }
  }
  if (res == 1e9)
    cout << "-1";
  else
    cout << res - 6;
  return 0;
}
