#include <bits/stdc++.h>
using namespace std;
int n, m, sum, res, d[4003], c[4003][4003];
vector<int> a[4003];
struct cmp {
  bool operator()(const int &u, const int &v) { return d[u] < d[v]; }
};
void test() {
  for (int i = 1; i <= n; i++) cout << d[i] << ' ';
  cout << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < a[i].size(); j++) cout << a[i][j] << ' ';
    cout << endl;
  }
}
void g(int x) {
  int tg = a[x].size() - 2;
  if (tg >= res) return;
  for (int u = 0; u < a[x].size() - 1; u++)
    for (int v = u + 1; v < a[x].size(); v++) {
      int p, q;
      p = a[x][u];
      q = a[x][v];
      if (c[p][q]) {
        int t = a[p].size() + a[q].size() + tg - 4;
        res = min(res, t);
      }
    }
  return;
}
int main() {
  memset(c, 0, sizeof(c));
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
    c[u][v] = 1;
    c[v][u] = 1;
  }
  for (int i = 1; i <= n; i++) d[i] = a[i].size();
  res = 1e9;
  for (int u = 1; u <= n; u++)
    if (d[u] >= 2) g(u);
  if (res > 10000000) {
    cout << -1;
    return 0;
  }
  cout << res;
}
