import java.util.*; public class Main { static int n; static int[][] matrix; static int max = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int m = sc.nextInt(); matrix = new int[n][n]; for (int i = 0; i < m; i++) { matrix[sc.nextInt()][sc.nextInt()] = sc.nextInt(); } search(0, 0, new HashSet()); System.out.println(max); } static void search(int idx, int score, HashSet used) { if (idx >= n) { max = Math.max(max, score); return; } for (int i = 0; i < n; i++) { if (used.contains(i)) { continue; } int added = 0; for (int x : used) { added += matrix[x][i]; } used.add(i); search(idx + 1, score + added, used); used.remove(i); } } }