#include <bits/stdc++.h>
using namespace std;
static const long long maxLL = (long long)1 << 62;
const long long MOD = 1000000007;
const long long INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int N, M;
struct MyStruct {
  vector<pair<int, int>> list;
};
struct StructKeiro {
  vector<pair<int, int>> list;
};
vector<MyStruct> stlist(200);
vector<vector<bool>> saitanHenFlag(200, vector<bool>(200, false));
vector<vector<int>> saitanHenKyori(200, vector<int>(200, 9999999));
vector<vector<StructKeiro>> saitanHenKyoriStruct(200, vector<StructKeiro>(200));
vector<bool> tyoFlag(200, false), tyoFlag2(200, false), tyoFlag3(200, false);
vector<pair<int, int>> mlist;
int start;
int func(int ima, int goal, int sum, StructKeiro st) {
  if (ima == goal) {
    if (saitanHenKyori[start][goal] > sum) {
      saitanHenKyori[goal][start] = sum;
      saitanHenKyori[start][goal] = sum;
      saitanHenKyoriStruct[start][goal] = st;
      saitanHenKyoriStruct[goal][start] = st;
    }
    return 0;
  }
  if (tyoFlag[ima] == true) {
    return 0;
  }
  tyoFlag[ima] = true;
  for (int i = 0; i < stlist[ima].list.size(); i++) {
    st.list.push_back(make_pair(ima, stlist[ima].list[i].first));
    func(stlist[ima].list[i].first, goal, sum + stlist[ima].list[i].second, st);
    st.list.pop_back();
  }
  return 0;
}
signed main() {
  StructKeiro st;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    stlist[a].list.push_back(make_pair(b, c));
    stlist[b].list.push_back(make_pair(a, c));
    mlist.push_back(make_pair(a, b));
    tyoFlag3[a] = true;
    tyoFlag3[b] = true;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (i == j) continue;
      if (saitanHenKyori[i][j] < 9999999 || saitanHenKyori[j][i] < 9999999)
        continue;
      start = i;
      func(i, j, 0, st);
      tyoFlag = tyoFlag2;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (tyoFlag3[i] == false) continue;
    for (int j = 1; j <= N; j++) {
      if (tyoFlag3[j] == false) continue;
      if (i == j) continue;
      for (int k = 0; k < saitanHenKyoriStruct[i][j].list.size(); k++) {
        saitanHenFlag[saitanHenKyoriStruct[i][j].list[k].first]
                     [saitanHenKyoriStruct[i][j].list[k].second] = true;
        saitanHenFlag[saitanHenKyoriStruct[i][j].list[k].second]
                     [saitanHenKyoriStruct[i][j].list[k].first] = true;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < mlist.size(); i++) {
    if (saitanHenFlag[mlist[i].first][mlist[i].second] == false) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
