#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, INF = 1e17;
using vi = vector<long long>;
using vvi = vector<vi>;
set<pair<long long, long long>> st;
vi via[110][110];
void dfs(long long goal, long long vp) {
  if (via[vp][goal].size() == 0) {
    st.insert({goal, vp});
    st.insert({vp, goal});
    return;
  }
  for (auto k = 0; k < via[vp][goal].size(); k++) {
    st.insert({vp, via[vp][goal][k]});
    st.insert({via[vp][goal][k], vp});
    dfs(goal, via[vp][goal][k]);
  }
}
signed main() {
  long long n, m;
  cin >> n >> m;
  long long mp[n][n];
  for (auto i = 0; i < n; i++)
    for (auto j = 0; j < n; j++) mp[i][j] = i == j ? 0 : INF;
  for (auto i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    mp[a][b] = mp[b][a] = c;
  }
  for (auto k = 0; k < n; k++)
    for (auto i = 0; i < n; i++)
      for (auto j = 0; j < n; j++) {
        if (mp[i][j] == mp[i][k] + mp[k][j]) {
        } else if (mp[i][j] > mp[i][k] + mp[k][j]) {
          mp[i][j] = mp[i][k] + mp[k][j];
          via[i][j].clear();
          via[i][j].push_back(k);
        }
      }
  for (auto i = 0; i < n; i++)
    for (auto j = i + 1; j < n; j++) {
      dfs(j, i);
    }
  cout << (m * 2 - (long long)st.size()) / 2 << endl;
}
