#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];
bool used[110][110][110] = {};
bool check(long long i, long long j) {
  set<long long> tr = {i, j};
  set<long long> cmp;
  for (auto k = 0; k < via[i][j].size(); k++) cmp.insert(via[i][j][k]);
  if (tr == cmp) {
    st.insert({i, j});
    st.insert({j, i});
    return true;
  }
  return false;
}
void dfs(long long goal, long long vp) {
  for (auto i = 0; i < via[goal][vp].size(); i++) {
    if (vp == via[goal][vp][i] || goal == via[goal][vp][i]) continue;
    st.insert({vp, via[goal][vp][i]});
    st.insert({via[vp][goal][i], vp});
    dfs(vp, via[goal][vp][i]);
  }
}
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]) {
          via[i][j].push_back(k);
        } 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++) {
      if (via[i][j].size() == 2 && check(i, j)) continue;
      for (auto k = 0; k < via[i][j].size(); k++) {
        if (via[i][j][k] == i || via[i][j][k] == j) continue;
        st.insert({i, via[i][j][k]});
        st.insert({via[i][j][k], i});
        dfs(j, via[i][j][k]);
      }
    }
  cout << m - st.size() / 2 << endl;
}
