#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int exp(long long int x, long long int y) {
  long long int res = 1;
  x = x % 1000000007;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
using namespace std;
const long long int nax = 5005;
long long int degree[nax];
bool t[nax][nax];
int main() {
  long long int n, m, i, j, k, a, b, ans = INT_MAX;
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> a >> b;
    t[a][b] = t[b][a] = true;
    degree[a]++;
    degree[b]++;
  }
  for (i = 1; i <= n; ++i) {
    for (j = i + 1; j <= n; ++j) {
      if (t[i][j]) {
        for (k = j + 1; k <= n; ++k) {
          if (t[i][k] && t[j][k])
            ans = min(ans, degree[i] + degree[j] + degree[k]);
        }
      }
    }
  }
  if (ans == INT_MAX)
    cout << -1;
  else
    cout << ans - 6;
  return 0;
}
