import java.io.*; import java.util.*; import java.math.*; class Main { static int max = 10 , n , ans = 0; static int[][] scoreBoard = new int[max][max]; static int[] prod; static boolean[] check; public static void out (Object o) { System.out.println(o); } public static int calc () { int ret = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ret += scoreBoard[prod[i]][prod[j]]; } } return ret; } public static void solve (int cnt) { if (cnt == n) ans = Math.max(ans , calc()); for (int i = 0; i < n; i++) { if (check[i]) continue; check[i] = true; prod[cnt] = i; solve(cnt + 1); check[i] = false; prod[cnt] = -1; } } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); n = Integer.parseInt(line[0]); int m = Integer.parseInt(line[1]); check = new boolean[n]; prod = new int[n]; Arrays.fill(prod , -1); for (int i = 0; i < m; i++) { line = br.readLine().split(" "); int a = Integer.parseInt(line[0]); int b = Integer.parseInt(line[1]); int c = Integer.parseInt(line[2]); scoreBoard[a][b] = c; } solve(0); out(ans); } }