#include <bits/stdc++.h>
using namespace std;
int num[4000 + 5], fri[4000 + 5][4000 + 5];
int main() {
  int n, m, x, y;
  while (~scanf("%d%d", &n, &m)) {
    memset(num, 0, sizeof(num));
    memset(fri, 0, sizeof(fri));
    while (m--) {
      scanf("%d%d", &x, &y);
      num[x]++;
      num[y]++;
      fri[x][y] = fri[y][x] = 1;
    }
    long long min_num = 0x3f3f3f3f, cnt;
    int flag = 0;
    for (int i = 1; i <= n - 2; i++) {
      if (num[i] < 2) continue;
      for (int j = i + 1; j <= n - 1; j++) {
        if (num[j] < 2) continue;
        if (fri[i][j] == 0) continue;
        for (int k = j + 1; k <= n; k++) {
          if (num[k] < 2) continue;
          if (fri[i][k] == 1 && fri[j][k] == 1) {
            flag = 1;
            cnt = num[i] + num[j] + num[k] - 6;
            if (cnt < min_num) {
              min_num = cnt;
            }
          }
        }
      }
    }
    if (flag == 0) min_num = -1;
    cout << min_num << endl;
  }
}
