#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> b, c, field;
int mul(int a, int b) {
  return (int)(((long long)(a % 1000000007) * (b % 1000000007)) % 1000000007);
}
int factorial(int n) {
  int ans = 1;
  for (int i = 1; i < n + 1; i++) {
    ans = ans * i;
  }
  return ans;
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> d(N, vector<int>(N, 500000000));
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < N; i++) d[i][i] = 0;
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  vector<int> isMinD(M, false);
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = 0; k < M; k++) {
        if (d[i][a[i]] + c[k] + d[b[i]][j] == d[i][j]) {
          isMinD[k] = true;
        }
      }
    }
  }
  int count = 0;
  for (int i = 0; i < M; i++)
    if (!isMinD[i]) count++;
  cout << count << endl;
  return 0;
}
