#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
const int N = 4e3 + 100;
const int M = N * 2;
bool mp[N][N];
vector<int> G[N];
int in[N];
int main() {
  int n, m;
  RD(n), RD(m);
  for (int i = 1; i <= int(m); i++) {
    int u, v;
    RD(u), RD(v);
    G[u].push_back(v);
    G[v].push_back(u);
    mp[u][v] = mp[v][u] = 1;
    in[v]++, in[u]++;
  }
  int minn = 1 << 25;
  for (int a = 1; a <= int(n); a++) {
    for (__typeof((G[a]).begin()) itb = (G[a]).begin(); itb != (G[a]).end();
         ++itb)
      for (__typeof((G[a]).begin()) itc = (G[a]).begin(); itc != (G[a]).end();
           ++itc) {
        if (itb == itc) continue;
        int b = *itb, c = *itc;
        if (mp[b][c]) {
          int tmp = in[a] + in[b] + in[c] - 6;
          if (minn > tmp) minn = tmp;
        }
      }
  }
  if (minn == 1 << 25)
    puts("-1");
  else
    printf("%d\n", minn);
}
