#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void maxi(T &x, T y) {
  if (y > x) x = y;
}
template <class T>
inline void mini(T &x, T y) {
  if (y < x) x = y;
}
const int N = 4e5, B = 0x7fffffff;
int n, m, k;
vector<pair<int, pair<int, int>>> g[N];
bool geldimi[N];
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,
               greater<pair<int, pair<int, int>>>>
    pq;
int need;
int main() {
  scanf("%d", &n), scanf("%d", &m), scanf("%d", &k);
  for (int i = 1; i <= m; i++) {
    int u, v, c;
    scanf("%d", &u), scanf("%d", &v), scanf("%d", &c);
    g[u].push_back(make_pair(0, make_pair(v, c)));
    g[v].push_back(make_pair(0, make_pair(u, c)));
  }
  for (int i = 1; i <= k; i++) {
    int u, c;
    scanf("%d", &u), scanf("%d", &c);
    g[1].push_back(make_pair(1, make_pair(u, c)));
    g[u].push_back(make_pair(1, make_pair(1, c)));
  }
  pq.push(make_pair(0, make_pair(0, 1)));
  while (!pq.empty()) {
    pair<int, pair<int, int>> tp = pq.top();
    pq.pop();
    if (geldimi[tp.second.second] == 1) continue;
    geldimi[tp.second.second] = 1;
    if (tp.second.first == 1) need++;
    for (pair<int, pair<int, int>> adj : g[tp.second.second])
      pq.push(make_pair(tp.first + adj.second.second,
                        make_pair(adj.first, adj.second.first)));
  }
  printf("%d", k - need);
  return !!0;
}
