#include <bits/stdc++.h>
using namespace std;
const int maxn = 4010;
const int INF = int(1e9);
int maps[maxn][maxn];
vector<int> num[maxn];
int main() {
  int a[maxn];
  int n, m;
  int b, c;
  int sum;
  while (~scanf("%d%d", &n, &m)) {
    memset(maps, 0, sizeof(maps));
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= n; i++) num[i].clear();
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &b, &c);
      num[b].push_back(c);
      num[c].push_back(b);
      maps[b][c] = maps[c][b] = 1;
      a[b]++;
      a[c]++;
    }
    sum = INF;
    for (int i = 1; i <= n; i++) {
      int a1 = i;
      for (int j = 0; j < num[i].size(); j++) {
        int b1 = num[i][j];
        for (int z = 0; z < num[b1].size(); z++) {
          int c1 = num[b1][z];
          if (maps[a1][b1] == 1 && maps[a1][c1] == 1 && maps[b1][c1] == 1)
            sum = min(sum, a[a1] + a[b1] + a[c1]);
        }
      }
    }
    if (sum == INF)
      printf("-1\n");
    else
      printf("%d\n", sum - 3 * 2);
  }
  return 0;
}
