#include <bits/stdc++.h>
using namespace std;
int dfs(vector<int>* v, int n) {
  int cost = -1;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (binary_search(v[i].begin(), v[i].end(), j) == 0) continue;
      for (int k = 0; k < v[i].size(); k++) {
        for (int s = 0; s < v[j].size(); s++) {
          if (v[i][k] == v[j][s]) {
            int p = v[i][k];
            int ct = v[i].size() + v[j].size() + v[p].size() - 6;
            if (cost == -1) {
              cost = ct;
            } else {
              cost = min(cost, ct);
            }
            break;
          }
        }
      }
    }
  }
  return cost;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v[n + 1];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i < n + 1; i++) {
    sort(v[i].begin(), v[i].end());
  }
  int cost = dfs(v, n);
  cout << cost << "\n";
  return 0;
}
