require 'set'

n, m = gets.split.map &:to_i

friend = (1..n).map{ [] }
cost = {}

(1..m).each{
	i, j, f = gets.split.map &:to_i
	i -= 1
	j -= 1
	friend[i] << j
	friend[j] << i
	cost[[i,j]] = f
	cost[[j,i]] = f
}

rabbits = (0..n-1).to_a

best = 0

until rabbits.empty? 
	i = rabbits.min_by{|i| friend[i].size}
	clique = [[]]

	f = friend[i]
	(1..(1<<friend[i].size)-1).each{|x|
		y = x & (x - 1)
		k = Math.log2(x ^ (x-1)).to_i
		if c = clique[y]
			if c.all?{|j| j == f[k] || friend[j].include?(f[k])}
				clique[x] = c + [f[k]]
			else
				clique[x] = nil
			end
		else
			clique[x] = nil
		end
	}

	clique.compact!
	clique.map!{|c| c + [i]}
	clique.select!{|c| c.size > 1}

	clique.each{|c|
		x = c.map{|i|
			(c - [i]).map{|j|
				cost[[i,j]]	
			}.min
		}.inject(:+)
		best = x if x > best
	}

	rabbits.delete(i)
	friend.map{|f| f.delete(i)}
end

p best