#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 100;
int d[MAX_V][MAX_V];
int ans[MAX_V][MAX_V] = {0};
void setCost(int d[MAX_V][MAX_V], int s, int e, int cost) {
  d[s][e] = d[e][s] = cost;
}
int main() {
  int V, M;
  cin >> V >> M;
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 1e8;
    }
  }
  int a, b, c;
  vector<pair<int, int> > edge;
  for (int i = 0; i < M; ++i) {
    cin >> a >> b >> c;
    setCost(d, a - 1, b - 1, c);
    edge.push_back(pair<int, int>(a - 1, b - 1));
  }
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int count = 0;
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (i == j) {
        continue;
      }
      for (int k = 0; k < V; ++k) {
        if (i == k || j == k) {
          continue;
        }
        if (d[i][j] == d[i][k] + d[k][j]) {
          for (int l = 0; l < edge.size(); ++l) {
            if (i == edge[l].first && k == edge[l].second ||
                k == edge[l].first && i == edge[l].second) {
              count++;
            }
          }
        }
      }
    }
  }
  cout << M - count << endl;
  return 0;
}
