#include <bits/stdc++.h>
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> v(n, vector<pair<int, int>>(0, {0, 0}));
  vector<vector<vector<int>>> p(n, vector<vector<int>>(n, vector<int>(1, -1)));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
    p[a][b][0] = b;
    p[b][a][0] = a;
  }
  vector<vector<int>> d(n, vector<int>(n, 1000000001));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      d[i][v[i][j].first] = v[i][j].second;
      d[v[i][j].first][i] = v[i][j].second;
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          p[i][j].clear();
          for (int s = 0; s < p[i][k].size(); ++s)
            p[i][j].push_back(p[i][k][s]);
          for (int t = 0; t < p[k][j].size(); ++t)
            p[i][j].push_back(p[k][j][t]);
        }
      }
    }
  }
  vector<vector<bool>> used(n, vector<bool>(n, false));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (p[i][j][0] != -1) {
        int a = i, b;
        for (int k = 0; k < p[i][j].size(); ++k) {
          b = p[i][j][k];
          used[a][b] = true;
          a = b;
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i != j && !used[i][j]) cnt++;
    }
  }
  cout << (cnt - m) / 2 << endl;
  return 0;
}
