#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[4004][4004];
int b[4004];
int x[4404];
int y[4004];
int ans = 100000000;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    a[x[i]][y[i]] = 1;
    a[y[i]][x[i]] = 1;
    b[x[i]]++;
    b[y[i]]++;
  }
  for (int i = 0; i < m; i++) {
    for (int o = 1; o <= n; o++) {
      if (a[x[i]][o] == 1 && a[y[i]][o] == 1) {
        ans = min(ans, b[x[i]] + b[y[i]] + b[o]);
      }
    }
  }
  if (ans == 100000000) {
    cout << "-1";
    return 0;
  }
  cout << ans - 6 << endl;
}
