CSES - Shared codeLink to this code: https://cses.fi/paste/f28396ef9920770e4c50e2/
#include<bits/stdc++.h>
using namespace std;
// #include "atcoder/math.hpp"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <functional> // for less
// using namespace __gnu_pbds;
// this is ordered_set in which we have all operations of sets. Additionally we have two more func:
// st.find_by_order(x); => this will return an iterator to the element at index x;
// st.order_of_key(x);=> this will return count of elements that are strictly less than x;
// replace DATA_TYPE with the data you want to store in the ordered_set
// replace less<DATA_TYPE> with any comparator you wish according to which the elements will be arranged.
// typedef tree< DATA_TYPE , null_type, less<DATA_TYPE>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//---------------------------ORDERED SET--------------------------------------
// template<typename T>
// using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// typedef tree<ll, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
// -----------------------------RANDOM NUMBER GENERATOR ---------------------
// #ifdef RNG
// unsigned seed=chrono::high_resolution_clock::now().time_since_epoch().count();
// mt19937 rng(seed);
// #endif
#define endl "\n"
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define set_bits __builtin_popcountll
#define precise(ans)  cout<<fixed<<setprecision(15)<<ans
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define sz(x) ((ll)(x).size())
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   prllf("%d\n",x)
#define pl(x)   prllf("%lld\n",x)
#define ps(s)   prllf("%s\n",s)
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define clr(x) memset(x, 0, sizeof(x))
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef pair<ll, ll>  pii;
typedef pair<ll, ll>    pl;
typedef vector<ll>     vi;
typedef vector<vi>      vvi;
typedef vector<vvi>    vvvi;
typedef vector<ll>      vl;
typedef vector<vl>      vvl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define MOD1 998244353
const double eps = 1e-9;
const ll INF = (ll) 1e9;
const ll inf64 = 2e18;
const ll INF64 = 9e18;
ll dx[4] = {0, 0, 1, -1}; ll dy[4] = {1, -1, 0, 0};
ll ddx[8] = { -1, 0, 0, 1, 1, -1, 1, -1};
ll ddy[8] = {0, 1, -1, 0, 1, -1, -1, 1};
const ll dddx[16] = {1, 0, 0, -1, 1, 1, -1, -1, 2, 2, 1, 1, -1, -1, -2, -2};
const ll dddy[16] = {0, -1, 1, 0, -1, 1, -1, 1, -1, 1, -2, 2, -2, 2, -1, 1};
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _prll(x); cerr << endl;
#else
#define debug(x)
#endif
void _prll(ll t) {cerr << t;} void _print(ll t) {cerr << t;} void _prll(string t) {cerr << t;} void _prll(char t) {cerr << t;}
void _prll(lld t) {cerr << t;} void _prll(double t) {cerr << t;} void _prll(ull t) {cerr << t;}
template <class T, class V> void _prll(pair <T, V> p); template <class T> void _prll(vector <T> v);
template <class T> void _prll(set <T> v);
template <class T, class V> void _prll(map <T, V> v); template <class T> void _prll(multiset <T> v);
template <class T, class V> void _prll(pair <T, V> p) {cerr << "{"; _prll(p.ff); cerr << ","; _prll(p.ss); cerr << "}";}
template <class T> void _prll(vector <T> v) {cerr << "[ "; for (T i : v) {_prll(i); cerr << " ";} cerr << "]";}
template <class T> void _prll(set <T> v) {cerr << "[ "; for (T i : v) {_prll(i); cerr << " ";} cerr << "]";}
template <class T> void _prll(multiset <T> v) {cerr << "[ "; for (T i : v) {_prll(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _prll(map <T, V> v) {cerr << "[ "; for (auto i : v) {_prll(i); cerr << " ";} cerr << "]";}
vector<ll> factors(ll n) {vector<ll> f; while (n % 2 == 0) {f.push_back(2) ;    n = n / 2  ;} for (ll x = 3; x * x <= n; x += 2) {while (n % x == 0) {f.push_back(x); n /= x;}} if (n > 1) f.push_back(n); return f;}
ull power(ull x , ull y,ll p) {ull res = 1; while (y > 0) { if (y & 1) res = res % p * x % p; y = y >> 1;  x = x % p * x % p;  } return res;}
bool palindrome(const string &s) {ll n = s.length(); for (ll i = 0; i < n; i++) {if (s[i] != s[n - i - 1]) return false;} return true;}
ll inv(ll a, ll p) {return power(a, p - 2,p);}
ll nCk(ll n, ll k, ll p, vl fact) {return ((fact[n] * inv(fact[k], p) % p) * inv(fact[n - k], p)) % p;}
bool isPrime(ll n) {if (n <= 1) {return false;} for (ll i = 2; i < n; i++) {if (n % i == 0) {return false;}} return true;}
map<ll, ll> primeFactorize(ll x) {ll num = x; map<ll, ll> store; for (ll i = 2; i <= sqrt(x); i++) {ll cnt = 0; while ((num % i) == 0) {num /= i; cnt++;} if (cnt) store[i] = cnt;} if (num > 1) store[num]++; return store;}
vl initfact(ll n, ll p = pow(10, 9) + 7) {vector<ll> fac(n + 1); fac[0] = 1; for (ll i = 1; i <= n; i++) {fac[i] = (fac[i - 1] * i) % p;} return fac;}
ll countSetBits(ll n) {ll count = 0; while (n) {count += n & 1; n >>= 1;} return count;}
ll int_sqrt (long long x) {long long ans = 0; for (ll k = 1LL << 30; k != 0; k /= 2) {if ((ans + k) * (ans + k) <= x) {ans += k;}} return ans;}
vector<ll>par;
vector<ll>rnk;
ll find(ll x){if(par[x]==x){return x;}else{return par[x]=find(par[x]);}}
void merge(ll x,ll y){ll px=find(x);ll py=find(y);if(rnk[px]>rnk[py]){par[py]=px;rnk[px]+=rnk[py];}else{par[px]=py;rnk[py]+=rnk[px];}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 
void chal() {
  ll n,m,k;
  cin>>n>>m>>k;
  vl aa(n);
  fo(i,n){
    cin>>aa[i];
  }
  multiset<ll> bb;
  fo(i,m){
    ll x;
    cin>>x;
    bb.insert(x);
  }
  ll ans=0;
  fo(i,n){
    auto it=lower_bound(bb.begin(),bb.end(),(aa[i]-k));
    if(it!=bb.end() && abs(*it-aa[i])<=(k)){
      // cout<<*it<<' '<<aa[i]<<' '<<abs(*it-aa[i])<<endl;
      bb.erase(it);
      ans++;
    }
  }
  cout<<ans<<endl;




} 
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("Error.txt", "w", stderr);
#endif
  ll  t;
  // cout << "Chal Raha Ha";
  t = 1;
  // ll tt = clock();
  // cin >> t;
  for (ll i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";
    chal();
  }
  // cerr << "TIME = " << clock() - tt << endl;
  // tt = clock();

  return 0;
}
//##############################################################################
//1.ReadProblemClearly.CheakCouterExamples.CheakIntuation.IfTimeProveIt#
//2.23l,BrteF,Math,NT(gcd,prime,seive),prefs,tPoint,SlidWind,stl(set,mapetc)#
//3.BinaryS(orlowerUpperbound,ans),dfs,bfs,dsu,bipartite,topo#
//4.Dp,opDP,sparshT,fenvickT,segmentT#
//##############################################################################