#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> adj[n + 1];
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int mn = INT_MAX;
  for (int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end());
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() >= 2) {
      for (int j = 0; j < adj[i].size(); j++) {
        if (adj[i][j] >= 2) {
          for (int k = j + 1; k < adj[i].size(); k++) {
            if (adj[i][k] >= 2) {
              if (binary_search(adj[adj[i][j]].begin(), adj[adj[i][j]].end(),
                                adj[i][k]) &&
                  binary_search(adj[adj[i][k]].begin(), adj[adj[i][k]].end(),
                                adj[i][j])) {
                mn = min(mn, (int)adj[adj[i][j]].size() +
                                 (int)adj[adj[i][k]].size() +
                                 (int)adj[i].size() - 6);
              }
            }
          }
        }
      }
    }
  }
  if (mn == INT_MAX)
    cout << -1 << endl;
  else
    cout << mn << endl;
}
