#include <bits/stdc++.h>
bool g[4001][4000];
using namespace std;
int main() {
  int answer = 0, ret = 0;
  int v1 = 0, v2 = 0, n = 4000, m = 4000;
  int num[4010];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    num[i] = 0;
    for (int j = 0; j < n; j++) {
      g[i][j] = false;
    }
  }
  answer = 100000;
  for (int i = 0; i < m; i++) {
    cin >> v1 >> v2;
    g[v1 - 1][v2 - 1] = true;
    g[v2 - 1][v1 - 1] = true;
    num[v1 - 1]++;
    num[v2 - 1]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (g[i][j]) {
        for (int k = j + 1; k < n; k++) {
          if (g[i][k] && g[j][k]) {
            ret = num[k] + num[i] + num[j] - 6;
            answer = min(ret, answer);
          }
        }
      }
    }
  }
  if (answer == 100000)
    printf("-1\n");
  else
    printf("%d\n", answer);
  return 0;
}
