#include <bits/stdc++.h>
using namespace std;
typedef struct node {
  int x, y;
} node;
node r[4005];
bool mat[4005][4005];
int a[4005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int i, j, x, y;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      mat[i][j] = 0;
    }
    a[i] = 0;
  }
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    mat[x][y] = 1;
    mat[y][x] = 1;
    r[i].x = x;
    r[i].y = y;
  }
  long long int temp;
  for (i = 0; i < n; i++) {
    temp = 0;
    for (j = 0; j < n; j++) {
      if (mat[i][j]) temp++;
    }
    a[i] = temp;
  }
  long long int ans = INT_MAX;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      temp = 0;
      if (j != r[i].x && j != r[i].y && mat[r[i].x][j] == 1 &&
          mat[r[i].y][j] == 1) {
        temp += (a[r[i].x] + a[r[i].y] + a[j]) - 6;
        ans = min(ans, temp);
      }
    }
  }
  if (ans == INT_MAX) ans = -1;
  cout << ans << endl;
  return 0;
}
