#include <bits/stdc++.h>
using namespace std;
const int nm = 4010;
const int inf = 1000000000;
int n, m;
vector<int> adj[nm];
bool a[nm][nm];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    a[u][v] = a[v][u] = 1;
  }
  int res = inf;
  for (int i = 1; i <= n; ++i) {
    for (int k = 0; k < adj[i].size(); ++k) {
      int j = adj[i][k];
      if (adj[i].size() < adj[j].size()) {
        for (int u = 0; u < adj[i].size(); ++u) {
          int v = adj[i][u];
          if (a[v][j])
            res = min(res,
                      int(adj[i].size() + adj[j].size() + adj[v].size()) - 6);
        }
      } else {
        for (int u = 0; u < adj[j].size(); ++u) {
          int v = adj[j][u];
          if (a[v][i])
            res = min(res,
                      int(adj[i].size() + adj[j].size() + adj[v].size()) - 6);
        }
      }
    }
  }
  if (res < inf)
    printf("%d\n", res);
  else
    printf("-1\n");
}
