#include <bits/stdc++.h>
using namespace std;
using P = pair<long, long>;
const int mod = 1000000007;
const int MAX_V = 105;
int d[MAX_V][MAX_V];
vector<int> nxt[MAX_V][MAX_V];
bool used[MAX_V][MAX_V];
void updateUsed(int start, int goal) {
  if (start == goal) return;
  for (auto i : nxt[start][goal]) {
    if (i != goal) {
      used[start][i] = true;
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) {
      d[i][j] = (1e9);
      nxt[i][j] = {j};
    }
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  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 (d[i][j] >= d[i][k] + d[k][j]) {
          if (d[i][j] == d[i][k] + d[k][j]) {
            (nxt[i][j]).insert((nxt[i][j]).end(), (nxt[i][k]).begin(),
                               (nxt[i][k]).end());
          } else {
            nxt[i][j] = {nxt[i][k]};
          }
          d[i][j] = d[i][k] + d[k][j];
        }
      }
  int res = m;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) {
      updateUsed(i, j);
    }
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(n); j++) {
      if (used[i][j]) {
        res--;
      }
    }
  cout << res << endl;
}
