#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, k;
cin >> n >> m >> k;
//vector<vector<bool> > roads(c, vector<bool>(c, false));
vector<int> size_applicant(n);
vector<int> apartments(m);
for (int i = 0; i < n; ++i) cin >> size_applicant[i];
for (int i = 0; i < m; ++i) cin >> apartments[i];
sort(size_applicant.begin(), size_applicant.end());
sort(apartments.begin(), apartments.end());
int ok = 0;
int app = 0, apart = 0;
while( app < n and apart < m) {
int app_value = size_applicant[app];
int apart_value = apartments[apart];
//cout << app << "---" << apart << endl;
//cout << app_value << "---" << apart_value << endl;
if (apart_value - k > app_value) ++app;
else if (app_value > apart_value + k) ++apart;
else {
++ok; ++app; ++apart;
}
}
cout << ok << endl;
}