def lgP4802():
from functools import lru_cache
dic={}
n,m=map(int,input().split())
st=(1<<(n-1))-2
graph=[[] for _ in range(n)]
for _ in range(m):
s,d,l=map(int,input().split())
if d==n-1:
dic[s]=l
else:
graph[s].append((d,l))
@lru_cache(None)
def f(x,st):
if st==0:
return dic[x] if x in dic else float('-inf')
ans=float('-inf')
for y,v in graph[x]:
if (st>>y)&1==1:
ans=max(ans,v+f(y,st^(1<<y)))
return ans
return f(0,st)
print(lgP4802())