#include <bits/stdc++.h>
using namespace std;
int a[4444][4444];
int p[4444], q[4444];
int cnt[4444] = {0};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) a[i][j] = 0;
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> q[i];
    a[p[i]][q[i]] = 1;
    a[q[i]][p[i]] = 1;
  }
  int sum = 4444444;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      cnt[i] += a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == p[i] || j == q[i]) continue;
      if (a[j][p[i]] == 0 || a[j][q[i]] == 0) continue;
      sum = min(sum, cnt[j] + cnt[p[i]] + cnt[q[i]] - 6);
    }
  }
  if (sum == 4444444)
    cout << "-1";
  else
    cout << sum << endl;
}
