#include <bits/stdc++.h>
using namespace std;
long long d[40000], dp[4010][4010];
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    dp[a][b] = 1;
    dp[b][a] = 1;
    d[a]++;
    d[b]++;
  }
  long long mn = 3e18;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (dp[i][j]) {
        for (int k = 1; k <= n; k++) {
          if (dp[i][k] && dp[j][k]) {
            mn = min(d[i] + d[j] + d[k], mn);
          }
        }
      }
    }
  }
  if (mn == 3e18) {
    cout << "-1" << endl;
  } else
    cout << mn - 6 << endl;
}
