from itertools import permutations N, M = map(int,input().split()) s = [[0]*N for _ in range(N)] for _ in range(M): a, b, c = map(int,input().split()) s[a][b] = c ans = 0 for p in permutations(range(N)): tans = 0 for i in range(N): for j in range(i+1,N): tans += s[p[i]][p[j]] ans = max(ans,tans) print(ans)