#include <bits/stdc++.h>
using namespace std;
bool conn[4001][4001];
vector<int> path[4001];
struct Edge {
  int a, b;
} edge[4001];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    edge[i].a = a;
    edge[i].b = b;
    conn[a][b] = conn[b][a] = true;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  int ans = 1000000;
  for (int i = 0; i < M; i++) {
    if (path[edge[i].a].size() >= 2 && path[edge[i].b].size() >= 2)
      for (int k = 0; k < M; k++) {
        if (path[edge[k].a].size() >= 2 && path[edge[k].b].size() >= 2)
          if (i == k) continue;
        int original = -1;
        int total = original = path[edge[i].a].size() + path[edge[i].b].size() +
                               path[edge[k].b].size() + path[edge[k].a].size() -
                               6;
        if (edge[i].a == edge[k].a) {
          if (conn[edge[i].b][edge[k].b])
            ans = min(ans, total - (int)path[edge[i].a].size());
        } else if (edge[i].a == edge[k].b) {
          if (conn[edge[i].b][edge[k].a])
            ans = min(ans, total - (int)path[edge[i].a].size());
        } else if (edge[i].b == edge[k].a) {
          if (conn[edge[i].a][edge[k].b])
            ans = min(ans, total - (int)path[edge[i].b].size());
        } else if (edge[i].b == edge[k].b) {
          if (conn[edge[i].a][edge[k].a])
            ans = min(ans, total - (int)path[edge[i].b].size());
        }
      }
  }
  if (ans == 1000000) ans = -1;
  cout << ans << "\n";
  return 0;
}
