import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class Main { static final int INF = 1000000000; static final long MOD = 1000000007; static final double EPS = 1e-10; public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); IO io = new IO(); String str[] = br.readLine().split(" "); int n = Integer.parseInt(str[0]); int m = Integer.parseInt(str[1]); int score[][] = new int[n][n]; for (int i = 0; i < m; i++) { str = br.readLine().split(" "); int a = Integer.parseInt(str[0]); int b = Integer.parseInt(str[1]); int s = Integer.parseInt(str[2]); score[a][b] = s; } int dp[] = new int[(1 << n)]; dp[0] = 0; for (int i = 0; i < n; i++) { for (int bit = 0; bit < (1 << n); bit++) { if ((bit & (1 << i)) != 0) continue; int cost = 0; for (int j = 0; j < n; j++) { if ((bit & (1 << j)) != 0) continue; cost += score[j][i]; } int now = ((bit | (1 << i))); dp[now] = Math.max(dp[now], dp[bit] + cost); } } System.out.println(dp[(1 << n) - 1]); } } class Pair { int to; int cost; public Pair(int to, int cost) { this.to = to; this.cost = cost; } } class IO { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public IO() { } public void println(String str) { System.out.println(str); } public void printArr(Object o[]) { for (int i = 0; i < o.length; i++) { System.out.print(o + " "); } System.out.println(); } public int getInt() throws IOException { return Integer.parseInt(br.readLine()); } public long getLong() throws IOException { return Long.parseLong(br.readLine()); } public double getDouble() throws IOException { return Double.parseDouble(br.readLine()); } public String getLine() throws IOException { return br.readLine(); } public int[] getIntArrPrim() throws IOException { String str[] = br.readLine().split(" "); int a[] = new int[str.length]; for (int i = 0; i < str.length; i++) { a[i] = Integer.parseInt(str[i]); } return a; } public Integer[] getIntArr() throws IOException { String str[] = br.readLine().split(" "); Integer a[] = new Integer[str.length]; for (int i = 0; i < str.length; i++) { a[i] = Integer.parseInt(str[i]); } return a; } public Long[] getLongArr() throws IOException { String str[] = br.readLine().split(" "); Long a[] = new Long[str.length]; for (int i = 0; i < str.length; i++) { a[i] = Long.parseLong(str[i]); } return a; } public long[] getLongArrPrim() throws IOException { String str[] = br.readLine().split(" "); long a[] = new long[str.length]; for (int i = 0; i < str.length; i++) { a[i] = Long.parseLong(str[i]); } return a; } public String[] getStrArr(String split) throws IOException { return br.readLine().split(split); } public char[] getCharArr() throws IOException { return br.readLine().toCharArray(); } public int[][] getIntMap(int w, int h, String split) throws IOException { int a[][] = new int[h][w]; for (int i = 0; i < h; i++) { String str[] = br.readLine().split(split); for (int j = 0; j < w; j++) { a[i][j] = Integer.parseInt(str[j]); } } return a; } public long[][] getLongMap(int w, int h, String split) throws IOException { long a[][] = new long[h][w]; for (int i = 0; i < h; i++) { String str[] = br.readLine().split(split); for (int j = 0; j < w; j++) { a[i][j] = Long.parseLong(str[j]); } } return a; } public double[][] getDoubleMap(int w, int h, String split) throws IOException { double a[][] = new double[h][w]; for (int i = 0; i < h; i++) { String str[] = br.readLine().split(split); for (int j = 0; j < w; j++) { a[i][j] = Double.parseDouble(str[j]); } } return a; } public char[][] getCharMap(int w, int h, String split) throws IOException { char a[][] = new char[h][w]; for (int i = 0; i < h; i++) { String str[] = br.readLine().split(split); for (int j = 0; j < w; j++) { a[i][j] = str[j].charAt(0); } } return a; } }