#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int mod = 1000000007;
const double pi = acos(-1);
inline void gn(long long& x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int& x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long& x) {
  long long t;
  gn(t);
  x = t;
}
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long x, long long mod) {
  long long t = 1ll;
  while (x) {
    if (x & 1) t = t * a % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return t;
}
const int maxn = 4005;
vector<pair<int, int> > gx;
int know[maxn];
bool ok[maxn][maxn];
int main() {
  memset((know), 0, sizeof(know));
  memset((ok), 0, sizeof(ok));
  int ans = inf;
  int pep, k, a, b;
  gn(pep);
  gn(k);
  while (k--) {
    gn(a);
    gn(b);
    gx.push_back(make_pair(a, b));
    know[a]++;
    know[b]++;
    ok[a][b] = true;
    ok[b][a] = true;
  }
  int sz = gx.size();
  for (int i = 0; i < sz; ++i) {
    int a = gx[i].first, b = gx[i].second;
    for (int i = (1); i <= (pep); i++) {
      if (ok[a][i] && ok[b][i] && know[a] + know[b] + know[i] - 6 < ans)
        ans = know[a] + know[b] + know[i] - 6;
    }
  }
  if (ans == inf) ans = -1;
  printf("%d\n", ans);
  return 0;
}
