#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> Graph[4005];
int minSum = -1;
bool isAdjacent(int x, int y) {
  for (vector<int>::iterator it = Graph[x].begin(); it != Graph[x].end(); it++)
    if (*it == y) return true;
  return false;
}
int Sum(int a, int b, int c) {
  int sum = 0;
  for (vector<int>::iterator it = Graph[a].begin(); it != Graph[a].end(); it++)
    if (*it != b && *it != c) sum++;
  for (vector<int>::iterator it = Graph[b].begin(); it != Graph[b].end(); it++)
    if (*it != a && *it != c) sum++;
  for (vector<int>::iterator it = Graph[c].begin(); it != Graph[c].end(); it++)
    if (*it != a && *it != b) sum++;
  return sum;
}
void SympleCycle(int node) {
  int n1, n2;
  if (Graph[node].size() < 2) return;
  for (int i = 0; i < Graph[node].size() - 1; i++) {
    n1 = Graph[node][i];
    for (int j = 1; j < Graph[node].size(); j++) {
      n2 = Graph[node][j];
      if (isAdjacent(n1, n2)) {
        if (minSum == -1)
          minSum = Sum(node, n1, n2);
        else
          minSum = min(minSum, Sum(node, n1, n2));
      }
    }
  }
}
int main() {
  cin >> N >> M;
  for (int x, y, i = 1; i <= M; i++) {
    cin >> x >> y;
    Graph[x].push_back(y);
    Graph[y].push_back(x);
  }
  for (int i = 1; i <= N; i++) SympleCycle(i);
  cout << minSum;
  return 0;
}
