#include <bits/stdc++.h>
using namespace std;
long long inf = 1e15, n;
const int N = 4e5 + 10;
long long dis[N];
long long sum;
int trn[N];
int frtrn[N];
int edg[N], par[N], ans;
vector<pair<pair<int, int>, int>> v[N];
map<pair<int, int>, int> mpno, mptrn;
void shortest(int u) {
  priority_queue<pair<int, int>> pq;
  pq.push({0, u});
  dis[u] = 0;
  while (!pq.empty()) {
    int from = pq.top().second;
    int cst = -pq.top().first;
    pq.pop();
    if (cst > dis[from]) continue;
    for (auto h : v[from]) {
      int to = h.first.first;
      int cstto = h.first.second;
      int id = h.second;
      if (dis[to] > dis[from] + cstto) {
        dis[to] = dis[from] + cstto;
        par[to] = from;
        pq.push({-dis[to], to});
      } else if (dis[to] == dis[from] + cstto && !trn[id]) {
        par[to] = from;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int k;
  for (int i = 1; i < N; i++) dis[i] = inf;
  for (int i = 1; i < N; i++) par[i] = i, dis[i] = inf;
  int n, i = 1, x, u, z, e, y;
  cin >> n >> e >> k;
  for (i = 1; i <= e; i++) {
    cin >> x >> y >> z;
    v[y].push_back({{x, z}, i});
    v[x].push_back({{y, z}, i});
    if (x > y) swap(x, y);
    int aa = mpno[{x, y}];
    if (!aa)
      mpno[{x, y}] = z;
    else
      mpno[{x, y}] = min(aa, z);
  }
  for (; i <= k + e; i++) {
    cin >> x >> y;
    trn[i] = 1;
    int aa = mptrn[{1, x}];
    if (!aa)
      mptrn[{1, x}] = y;
    else
      mptrn[{1, x}] = min(aa, y);
    v[1].push_back({{x, y}, i});
    v[x].push_back({{1, y}, i});
  }
  shortest(1);
  {
    for (int j = 0; j < v[1].size(); j++) {
      int child = v[1][j].first.first;
      int cstt = v[1][j].first.second;
      int wtr = mptrn[{1, child}];
      int wno = mpno[{1, child}];
      if (par[child] == 1) {
        if (dis[child] == wtr && (!wno || wno > wtr)) {
          mptrn[{1, child}] = 0;
          mpno[{1, child}] = 0;
          ans++;
        }
      }
    }
  }
  cout << k - ans;
}
