#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const int inf = 1e9;
int main() {
  cin.sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int pass[100][100];
  memset(pass, inf, sizeof(pass));
  int a, b, c;
  bool flag[100][100] = {};
  for (int i = 0; i < (int)(M); i++) {
    cin >> a >> b >> c;
    pass[a][b] = pass[b][a] = c;
    flag[a][b] = flag[b][a] = true;
  }
  for (int k = 0; k < (int)(N); k++) {
    for (int i = 0; i < (int)(N); i++) {
      for (int j = 0; j < (int)(N); j++) {
        if (pass[i][k] < pass[i][k] + pass[k][j]) {
          flag[i][j] = false;
          flag[i][k] = flag[k][j] = true;
          pass[i][j] = pass[i][k] + pass[k][j];
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(N); j++)
      if (flag[i][j]) count++;
  }
  cout << M - count / 2 << endl;
  return 0;
}
