#include <bits/stdc++.h>
using namespace std;
int a[4010][4010];
int n, m;
int u[4010], v[4010], sz[4010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u[i], &v[i]);
    a[u[i]][v[i]] = a[v[i]][u[i]] = 1;
    sz[u[i]]++;
    sz[v[i]]++;
  }
  int ans = 1e9;
  for (int i = 1; i <= m; i++) {
    int x = u[i], y = v[i];
    for (int j = i + 1; j <= m; j++) {
      int c = u[j], d = v[j];
      if (x == c && a[y][d] == 1) {
        ans = min(ans, sz[x] + sz[y] + sz[d] - 6);
      } else if (x == d && a[y][c] == 1) {
        ans = min(ans, sz[x] + sz[c] + sz[y] - 6);
      } else if (y == c && a[x][d] == 1) {
        ans = min(ans, sz[y] + sz[x] + sz[d] - 6);
      } else if (y == d && a[x][c] == 1) {
        ans = min(ans, sz[y] + sz[x] + sz[c] - 6);
      }
    }
  }
  if (ans == 1e9)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
