#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-14;
const double PI = acos(-1.0);
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int a, b, c;
  int cost[n][n];
  int use[n][n];
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(n); j++) {
      if (i == j)
        cost[i][j] = 0;
      else
        cost[i][j] = INT_MAX / 3;
      use[i][j] = -1;
    }
  }
  for (int i = (int)(0); i < (int)(m); i++) {
    scanf("%d %d %d", &a, &b, &c);
    a--;
    b--;
    cost[a][b] = c;
    cost[b][a] = c;
    use[a][b] = 1;
    use[b][a] = 1;
  }
  for (int i = (int)(0); i < (int)(n); i++)
    for (int j = (int)(0); j < (int)(n); j++)
      for (int k = (int)(0); k < (int)(n); k++) {
        if (cost[j][k] > cost[j][i] + cost[i][k]) {
          cost[j][k] = cost[j][i] + cost[i][k];
          use[j][k]--;
          use[j][i]++;
          use[i][k]++;
        }
      }
  int cnt = 0;
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(n); j++) {
      if (use[i][j] == 0) cnt++;
    }
  }
  cout << cnt / 2 << endl;
}
