#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int res = 0;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
const int N = 100010;
int rd[N];
vector<int> v[N];
int main() {
  int n = in(), m = in();
  for (int i = 0; i < m; i++) {
    int t1 = in(), t2 = in();
    rd[t1]++, rd[t2]++;
    v[t1].push_back(t2);
    v[t2].push_back(t1);
  }
  int ans = 0x3f3f3f3f;
  for (int p = 1; p <= n; p++)
    if (rd[p] >= 2)
      for (int i = 0; i < (int)v[p].size(); i++) {
        int tt = v[p][i];
        if (rd[tt] >= 2) {
          for (int j = 0; j < (int)v[tt].size(); j++) {
            int ttt = v[tt][j];
            if (rd[v[tt][j]] >= 2) {
              for (int k = 0; k < (int)v[ttt].size(); k++) {
                if (v[ttt][k] == p) {
                  int tmp = rd[p] - 2 + rd[tt] - 2 + rd[ttt] - 2;
                  ans = min(ans, tmp);
                  break;
                }
              }
            }
          }
        }
      }
  printf("%d\n", ans == 0x3f3f3f3f ? -1 : ans);
  return 0;
}
