#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
void warshall_floyd(vector<vector<int>> &d, int V, vector<vector<int>> &next) {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          next[i][j] = next[i][k];
        }
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(n, vector<int>(n, (1 << 30)));
  vector<vector<int>> next(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      next[i][j] = j;
    }
  }
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  warshall_floyd(d, n, next);
  set<pair<int, int>> st;
  for (int s = 0; s < n; s++) {
    for (int g = 0; g < n; g++) {
      vector<int> tmp;
      for (int now = s; now != g; now = next[now][g]) {
        tmp.push_back(now);
      }
      int sz = tmp.size();
      for (int i = 0; i < sz - 1; i++) {
        int a = tmp[i];
        int b = tmp[i + 1];
        if (a > b) {
          swap(a, b);
        }
        st.insert(make_pair(a, b));
      }
    }
  }
  int ans = m - st.size();
  cout << ans << endl;
}
