#include <bits/stdc++.h>
const int INF = 100000000;
const double EPS = 1e-10;
const int MOD = 1000000007;
using namespace std;
int n, m, a, b, c, sum;
int d[1010][1010], dist[1010][1010];
int q[1010];
vector<pair<int, int>> edge[1010];
void dj(int s) {
  for (int i = 1; i <= n; i++) q[i] = 1;
  sum = n;
  while (sum > 0) {
    int mn = 100010, vm = 1;
    for (int i = 1; i <= n; i++) {
      if (q[i] == 1) {
        if (mn >= dist[s][i]) {
          mn = dist[s][i];
          vm = i;
        }
      }
    }
    q[vm] = 0;
    sum--;
    for (int i = 0; i < edge[vm].size(); i++) {
      if (d[s][edge[vm][i].first] > d[s][vm] + edge[vm][i].second) {
        d[s][edge[vm][i].first] = d[s][vm] + edge[vm][i].second;
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 100010;
    }
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    edge[a].push_back(make_pair(b, c));
    edge[b].push_back(make_pair(a, c));
  }
  for (int i = 1; i <= n; i++) dj(i);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < edge[i].size(); j++) {
      a = i;
      b = edge[i][j].first;
      c = edge[i][j].second;
      if (c != d[a][b]) ans += 1;
    }
  cout << (ans / 2) << endl;
  ;
}
