#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vertex[101];
vector<int> tips[101];
vector<int> enemy[101];
int oops[10000] = {};
int main() {
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    enemy[a].push_back(vertex[b].size());
    enemy[b].push_back(vertex[a].size());
    vertex[a].push_back(make_pair(b, c));
    tips[a].push_back(i);
    vertex[b].push_back(make_pair(a, c));
    tips[b].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    pair<int, int> shortest[200] = {};
    int done[200] = {};
    for (long long i = 0; i < 200; ++i) {
      shortest[i].first = 10000000;
    }
    priority_queue<pair<int, int>> hogee;
    hogee.push(make_pair(0, i));
    shortest[i].first = 0;
    shortest[i].second = -1;
    while (hogee.empty() == false) {
      int now = hogee.top().second;
      hogee.pop();
      if (done[now] == false) {
        done[now] = true;
        for (int q = 0; q < vertex[now].size(); ++q) {
          if (vertex[now][q].second + shortest[now].first <
              shortest[vertex[now][q].first].first) {
            shortest[vertex[now][q].first].first =
                vertex[now][q].second + shortest[now].first;
            shortest[vertex[now][q].first].second = enemy[now][q];
            hogee.push(make_pair(shortest[vertex[now][q].first].first,
                                 vertex[now][q].first));
          }
        }
      }
    }
    for (int j = i + 1; j <= n; ++j) {
      queue<int> quake;
      quake.push(j);
      while (quake.empty() == false) {
        int hoge = quake.front();
        quake.pop();
        if (shortest[hoge].second != -1) {
          quake.push(vertex[hoge][shortest[hoge].second].first);
          oops[tips[hoge][shortest[hoge].second]] = 1;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    if (oops[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
