#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time


(n, m) = (int(i) for i in input().split())
A = { i:[] for i in range(n) }
d = [ 0 for i in range(n) ]

for i in range(m):
    (a, b) = (int(i) for i in input().split())
    a -= 1
    b -= 1

    A[a] += [b]
    A[b] += [a]
    d[a] += 1
    d[b] += 1

start = time.time()

for i in range(n):
    d[i] -= 2

ans = -1
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        if j in A[i]:
            for k in range(n):
                if i == k or j == k:
                    continue

                if k in A[j] and k in A[i]:
                    if ans == -1 or  d[i]+d[j]+d[k] < ans:
                        ans = d[i]+d[j]+d[k]


print(ans)
finish = time.time()
#print(finish - start)