import java.util.*; import java.io.*; public class Main { static int n; static ArrayList> list = new ArrayList<>(); static int max = 0; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); n = sc.nextInt(); int m = sc.nextInt(); for (int i = 0; i < n; i++) { list.add(new HashMap<>()); } for (int i = 0; i < m; i++) { int left = sc.nextInt(); int right = sc.nextInt(); int score = sc.nextInt(); list.get(right).put(left, score); } setMax(0, 0, new HashSet<>()); System.out.println(max); } static void setMax(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; } used.add(i); int tmp = 0; for (int x : list.get(i).keySet()) { if (used.contains(x)) { tmp += list.get(i).get(x); } } setMax(idx + 1, score + tmp, used); used.remove(i); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }