#include <bits/stdc++.h>
using namespace std;
int ans = -1;
bool connected[4000][4000];
vector<vector<int> > edgeList;
void dfs(int current, int child, int grandChild) {
  if (child == -1) {
    for (int i = 0; i < edgeList[current].size(); i++) {
      if (edgeList[edgeList[current][i]].size() >= 2) {
        dfs(current, edgeList[current][i], -1);
      }
    }
  } else if (grandChild == -1) {
    for (int i = 0; i < edgeList[child].size(); i++) {
      if (edgeList[child][i] != current &&
          edgeList[edgeList[child][i]].size() >= 2) {
        dfs(current, child, edgeList[child][i]);
      }
    }
  } else {
    if (!connected[grandChild][current]) {
      return;
    } else {
      int sum = edgeList[current].size() + edgeList[child].size() +
                edgeList[grandChild].size() - 6;
      if (ans == -1 || sum < ans) {
        ans = sum;
      }
    }
  }
}
int main() {
  int V, E, A, B;
  scanf("%d%d", &V, &E);
  edgeList.assign(V, vector<int>());
  for (int i = 0; i < E; i++) {
    scanf("%d%d", &A, &B);
    A--;
    B--;
    edgeList[A].push_back(B);
    edgeList[B].push_back(A);
    connected[A][B] = true;
    connected[B][A] = true;
  }
  for (int i = 0; i < V; i++) {
    if (edgeList[i].size() >= 2) {
      dfs(i, -1, -1);
    }
  }
  printf("%d\n", ans);
  return 0;
}
