/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static int dfs(final int N, int deep, boolean[] selected, int[] items, int[][] scores){ if(deep < N){ int max = 0; for(int i = 0; i < N; i++){ if(!selected[i]){ selected[i] = true; items[deep] = i; max = Math.max(max, dfs(N, deep + 1, selected, items, scores)); selected[i] = false; } } return max; }else{ int score = 0; for(int fst = 0; fst < N; fst++){ for(int snd = fst + 1; snd < N; snd++){ score += scores[items[fst]][items[snd]]; } } return score; } } public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int M = sc.nextInt(); int[][] scores = new int[N][N]; for(int i = 0; i < M; i++){ final int A = sc.nextInt(); final int B = sc.nextInt(); final int score = sc.nextInt(); scores[A][B] = Math.max(scores[A][B], score); } System.out.println(dfs(N, 0, new boolean[N], new int[N], scores)); } }