import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[][] a = new int[N][N];
        int[][] b = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (i!=j)
                    b[i][j] = Integer.MAX_VALUE/4;
            }
        }

        for (int i = 0; i < M; i++) {
            int v1 = scanner.nextInt() - 1;
            int v2 = scanner.nextInt() - 1;
            int c = scanner.nextInt();
            a[v1][v2] = a[v2][v1] = b[v1][v2] = b[v2][v1] = c;
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    b[i][j] = Math.min(b[i][j],b[i][k]+b[k][j]);
                }
            }
        }
        int ret = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                if (a[i][j]>b[i][j])
                    ret++;
            }
        }
        System.out.println(ret);
    }
}