#include <bits/stdc++.h>
using namespace std;
long long n, a[10000], b[10000], m, lqb[10000], kq = -1;
bool qb[4001][4001];
void doc() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    lqb[a[i]]++;
    lqb[b[i]]++;
    qb[a[i]][b[i]] = true;
    qb[b[i]][a[i]] = true;
  }
}
void xl() {
  long x, y;
  for (int i = 1; i <= m; i++) {
    x = a[i];
    y = b[i];
    for (int i = 1; i <= n; i++) {
      if (qb[x][i] and qb[y][i] and x != i and x != y and y != i) {
        if (kq == -1)
          kq = lqb[x] + lqb[y] + lqb[i] - 6;
        else
          kq = min(kq, lqb[x] + lqb[y] + lqb[i] - 6);
      }
    }
  }
  cout << kq;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  doc();
  xl();
}
