#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T const& Max(T const& a, T const& b) {
  return a > b ? a : b;
}
template <typename T>
T const& Min(T const& a, T const& b) {
  return a < b ? a : b;
}
template <typename T>
inline T gcd(T a, T b) {
  return (b ? gcd(b, a % b) : a);
}
template <typename T>
T sqaa(T a) {
  return a * a;
}
template <typename T>
inline T powa(T x, T p) {
  if (!p)
    return 1;
  else if (p & 1)
    return x * powa(x, p - 1);
  else {
    T ret = powa(x, p >> 1);
    return ret * ret;
  }
}
bitset<4001> ar[4001];
vector<int> G[4001];
int main() {
  int n, m, a, b, ll, ans;
  vector<int> KK;
  while (scanf("%d %d", &n, &m) != EOF) {
    KK.clear();
    for (int i = (0); i < (m); i++) {
      scanf("%d %d", &a, &b);
      ar[a][b] = 1;
      ar[b][a] = 1;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    int x, y;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < G[i].size(); j++) {
        x = G[i][j];
        for (int k = j + 1; k < G[i].size(); k++) {
          y = G[i][k];
          if (ar[x][y]) {
            ans = 0;
            ans += (int)(G[i]).size() + (int)(G[x]).size() +
                   (int)(G[y]).size() - 6;
            KK.push_back(ans);
          }
        }
      }
    }
    if (KK.size() == 0) {
      cout << -1 << "\n";
    } else {
      sort((KK).begin(), (KK).end());
      cout << KK[0] << "\n";
    }
  }
  return 0;
}
