import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

    static private Reader reader = new Reader();

    public static void main(String[] args) {
        int t = reader.nextInt();
        while(t-- > 0) {
            int n = reader.nextInt();
            Set<Integer> result = new HashSet<>();
            int a = 2;
            while(a*a <= n) {
                if(n % a == 0) {
                    result.add(a);
                    break;
                }
                a++;
            }
            int b = a+1;
            while(b*b <= n) {
                if(n % b == 0) {
                    result.add(b);
                    break;
                }
                b++;
            }
            n /= a;
            n /= b;
            result.add(n);
            if(result.size() == 3 && n != 1) {
                System.out.println("YES");
                for (Integer integer : result) {
                    System.out.print(integer+ " ");
                }
                System.out.println();
            } else {
                System.out.println("NO");
            }
        }
    }

    static class Reader {

        private StringTokenizer st;
        private BufferedReader br;

        Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}


import javafx.util.Pair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    static Reader reader = new Reader();

    public static void main(String[] args) {
        int t = reader.nextInt();
        while (t-- > 0) {
            int n = reader.nextInt();
            List<Integer> div = new ArrayList<>();
            for(int i = 2; i <= n / 2; i++) {
                if(n % i == 0) {
                    div.add(i);
                }
            }
            boolean result = false;
            for(int i = 0; i < div.size(); i++) {
                int x = n / div.get(i);
                for(int j = 0, k = div.size() - 1; j < k; ) {
                    if(j == i) {
                        j++;
                    } else if(k == i) {
                        k--;
                    } else if(div.get(j) * div.get(k) == x) {
                        System.out.println("YES\n" + div.get(i) + " " + div.get(j) + " " + div.get(k));
                        result = true;
                        break;
                    } else if(div.get(j) * div.get(k) > x) {
                        k--;
                    } else {
                        j++;
                    }
                }
                if(result) {
                    break;
                }
            }
            if(!result) {
                System.out.println("NO");
            }
        }
    }

    static class Reader {
        private BufferedReader br;
        private StringTokenizer st;

        Reader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Arrays;

/**
 * @author Alice
 */
public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner str = new Scanner(System.in);
		int t = str.nextInt();
		for(int i = 0; i < t; i++) {
			int number = str.nextInt();
			int count = 0, temp1 = 0, temp2 = 0, temp3 = 0;
			for(int j = 2; j < number; j++) {
				if(number%j == 0) {
					count++;
					number /= j;
					if(count == 1) temp1 = j;
					if(count == 2) {
						temp2 = j;
						temp3 = number;
//						break;
					}
				}
			}
			if(temp2 == temp3 || count < 2) {
				System.out.println("NO");
			}else {
				System.out.println("YES");
				System.out.println(temp1 + " " + temp2 + " " + temp3);
			}
		}
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Arrays;

/**
 * @author Alice
 */
public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner str = new Scanner(System.in);
		int t = str.nextInt();
		for(int i = 0; i < t; i++) {
			int number = str.nextInt();
			int count = 0, temp1 = 0, temp2 = 0, temp3 = 0;
			for(int j = 2; j < number; j++) {
				if(number%j == 0) {
					count++;
					number /= j;
					if(count == 1) temp1 = j;
					if(count == 2) {
						temp2 = j;
						temp3 = number;
//						break;
					}
				}
			}
			if(temp2 >= temp3 || count < 2) {
				System.out.println("NO");
			}else {
				System.out.println("YES");
				System.out.println(temp1 + " " + temp2 + " " + temp3);
			}
		}
    }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Arrays;

/**
 * @author Alice
 */
public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner str = new Scanner(System.in);
		int t = str.nextInt();
		for(int i = 0; i < t; i++) {
			int number = str.nextInt();
			int count = 0, temp1 = 0, temp2 = 0, temp3 = 0;
			for(int j = 2; j < number; j++) {
				if(number%j == 0) {
					count++;
					number /= j;
					if(count == 1) temp1 = j;
					if(count == 2) {
						temp2 = j;
						temp3 = number;
						break;
					}
				}
			}
			if(temp2 >= temp3 || count < 2) {
				System.out.println("NO");
			}else {
				System.out.println("YES");
				System.out.println(temp1 + " " + temp2 + " " + temp3);
			}
		}
    }
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
    vector<int>b,g;
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    int a;
    cin>>a;
    b.push_back(a);
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        int a;
        cin>>a;
        g.push_back(a);
    }
    sort(b.begin(),b.end());
    sort(g.begin(),g.end());
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(abs(b[i]-g[j])<=1)
            {
                ans++;
                g[j]=100;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
    vector<int>b,g;
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    int a;
    cin>>a;
    b.push_back(a);
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        int a;
        cin>>a;
        g.push_back(a);
    }
    sort(b.begin(),b.end());
    sort(g.begin(),g.end());
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(abs(b[i]-g[j])<=1)
            {
                ans++;
                g[j]=1000;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <math.h>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <complex>
#include <climits>
#include <iomanip>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vec;
typedef vector<double> vecd;
typedef vector<ll> vecl;
typedef pair<int, int> pr;
typedef complex <double> t_compl;

const double PI = 3.141592653589793;
const double E = 2.7182818284590452354;

#define all(a)  a.begin(),a.end()
#define min(a, b) ((a < b) ? (a) : (b))
#define max(a, b) ((a > b) ? (a) : (b))
#define abs(a) ((a < 0) ? (-(a)) : (a))
#define pb push_back
#define mp make_pair
#define sz size
#define X first
#define Y second

#define EPS 0.00001
#define E 2.71828182845904523536
int main()
{
    int n, m, a[200], b[200];

    cin >> n;
    for(int i = 0; i < n; ++i)
     cin >> a[i];

    cin >> m;
    for(int i = 0; i < m; ++i)
     cin >> b[i];
    sort(a, a+n);
    sort(b, b+m);
    int  ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
        {
            if (abs(a[i]-b[j]) <= 1)
            {
                a[i] = 10000000;
                ans++;
                break;
            }
        }
    cout << ans;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <math.h>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <complex>
#include <climits>
#include <iomanip>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vec;
typedef vector<double> vecd;
typedef vector<ll> vecl;
typedef pair<int, int> pr;
typedef complex <double> t_compl;

const double PI = 3.141592653589793;
const double E = 2.7182818284590452354;

#define all(a)  a.begin(),a.end()
#define min(a, b) ((a < b) ? (a) : (b))
#define max(a, b) ((a > b) ? (a) : (b))
#define abs(a) ((a < 0) ? (-(a)) : (a))
#define pb push_back
#define mp make_pair
#define sz size
#define X first
#define Y second

#define EPS 0.00001
#define E 2.71828182845904523536
int main()
{
    int n, m, a[200], b[200];

    cin >> n;
    for(int i = 0; i < n; ++i)
     cin >> a[i];

    cin >> m;
    for(int i = 0; i < m; ++i)
     cin >> b[i];
    sort(a, a+n);
    sort(b, b+m);
    int  ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            if (abs(a[i]-b[j]) <= 1)
            {
                b[j] = 1000;
                ans++;
                break;
            }

    cout << ans;
    return 0;
}


#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

int n;
int m;
int nums[110],nums2[110];

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  rep(i,n){
    cin >> nums[i];
  }
  cin >> m;
  rep(i,m){
    cin >> nums2[i];
  }
  sort(nums,nums+n);
  sort(nums2,nums2+m);
  int ans = 0;
  {
    int j = 0;
    for(int i = 0;i < n;i++){
      for(;j < m;j++){
        if(abs(nums[i]-nums2[j]) <= 1){
          ans += 1;
          j++;
          break;
        }else if(nums[i] > nums2[j]){
          j++;
        }else{
          break;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

int n;
int m;
int nums[110],nums2[110];

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n;
  rep(i,n){
    cin >> nums[i];
  }
  cin >> m;
  rep(i,m){
    cin >> nums2[i];
  }
  sort(nums,nums+n);
  sort(nums2,nums2+m);
  int ans = 0;
  {
    int j = 0;
    for(int i = 0;i < n;i++){
      for(;j < m;j++){
        if(abs(nums[i]-nums2[j]) <= 1){
          ans += 1;
          j++;
          break;
        }else if(nums[i] > nums2[j]){
          ;
        }else{
          break;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


#include "bits/stdc++.h"

#define sortv(x) sort(x.begin(), x.end())
#define sorta(array, tamano) sort(array, array+tamano)
#define read(start, end, get) for (; start < end; start++) cin >> get[start];
#define sum(start, end, get) for (; start < end; start++) {int p; cin >> p; get+=p;}
#define MODULE (1e9+7)
#define pb(w) push_back(w)
#define f first
#define s second

typedef long long int lli;
typedef unsigned long long ull;

using namespace std;
int arrn[109];
int arrm[109];
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >>n;
    for (int i = 0; i < n; ++i)
        cin >> arrn[i];
    cin >> m;
    for (int i = 0; i < m; ++i)
        cin >> arrm[i];

    sort(arrm, arrm+m);
    sort(arrn, arrn+n);
    int path = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if ( arrm[j]!=-100 && abs(arrn[i]-arrm[j]) < 2){
                arrm[j] = -100;
                path++;
                break;
            }
        }
    }
    cout << path << endl;
    return 0;
}


#include "bits/stdc++.h"

#define sortv(x) sort(x.begin(), x.end())
#define sorta(array, tamano) sort(array, array+tamano)
#define read(start, end, get) for (; start < end; start++) cin >> get[start];
#define sum(start, end, get) for (; start < end; start++) {int p; cin >> p; get+=p;}
#define MODULE (1e9+7)
#define pb(w) push_back(w)
#define f first
#define s second

typedef long long int lli;
typedef unsigned long long ull;

using namespace std;
int arrn[109];
int arrm[109];
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >>n;
    for (int i = 0; i < n; ++i)
        cin >> arrn[i];
    cin >> m;
    for (int i = 0; i < m; ++i)
        cin >> arrm[i];

    int path = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if ( arrm[j]!=-100 && abs(arrn[i]-arrm[j]) < 2){
                arrm[j] = -100;
                path++;
                break;
            }
        }
    }
    cout << path << endl;
    return 0;
}


#include "bits/stdc++.h"

#define sortv(x) sort(x.begin(), x.end())
#define sorta(array, tamano) sort(array, array+tamano)
#define read(start, end, get) for (; start < end; start++) cin >> get[start];
#define sum(start, end, get) for (; start < end; start++) {int p; cin >> p; get+=p;}
#define MODULE (1e9+7)
#define pb(w) push_back(w)
#define f first
#define s second

typedef long long int lli;
typedef unsigned long long ull;

using namespace std;
int arrn[109];
int arrm[109];
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >>n;
    for (int i = 0; i < n; ++i)
        cin >> arrn[i];
    cin >> m;
    for (int i = 0; i < m; ++i)
        cin >> arrm[i];

    int path = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; j++){
            if (abs(arrn[i]-arrm[j]) < 2 && arrn[i]!=0 && arrm[j]!=0){
                arrm[j] = 0;
                arrn[i] = 0;
                path++;
                break;
            }
        }
    }
    cout << path << endl;
    return 0;
}


#include "bits/stdc++.h"

#define sortv(x) sort(x.begin(), x.end())
#define sorta(array, tamano) sort(array, array+tamano)
#define read(start, end, get) for (; start < end; start++) cin >> get[start];
#define sum(start, end, get) for (; start < end; start++) {int p; cin >> p; get+=p;}
#define MODULE (1e9+7)
#define pb(w) push_back(w)
#define f first
#define s second

typedef long long int lli;
typedef unsigned long long ull;

using namespace std;
int arrn[109];
int arrm[109];
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >>n;
    for (int i = 0; i < n; ++i)
        cin >> arrn[i];
    cin >> m;
    for (int i = 0; i < m; ++i)
        cin >> arrm[i];

    sort(arrm, arrm+m);
    sort(arrn, arrn+n);
    int path = 0;
    for (int i = 0; i < n; i++){
        for (int j = (m-1); j >= 0; j--){
            if ( arrm[j]!=-100 && abs(arrn[i]-arrm[j]) < 2){
                arrm[j] = -100;
                path++;
                break;
            }
        }
    }
    cout << path << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n;
    int ans = 0;
    int hash[102] = {0};
    vector<int> boys,girls;
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        boys.push_back(temp);
        hash[temp] += 1;
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int temp;
        cin >> temp;
        girls.push_back(temp);
        if(hash[temp-1] >0){
            ans++;
            hash[temp-1]--;
        }
        else if(hash[temp+1] > 0){
            ans++;
            hash[temp+1]--;
        }
        else if(hash[temp] > 0){
            ans++;
            hash[temp]--;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cin >> n;
    vector<int> boys, girls;
    for(int i=0;i<n;i++){
        int temp; cin >> temp;
        boys.push_back(temp);
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int temp; cin >> temp;
        girls.push_back(temp);
    }
    sort(boys.begin(),boys.end());
    sort(girls.begin(),girls.end());
    int b = 0, g = 0, ans = 0;
    while( b<n && g<n ){
        if(abs(girls[g]-boys[b]) <= 1){
            ans++;
            g++;
            b++;
        }
        else if(girls[g] > boys[b]){
            b++;
        }
        else{
            g++;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n;
    int ans = 0;
    int hash[102] = {0};
    vector<int> boys,girls;
    for(int i=0;i<n;i++){
        int temp;
        cin >> temp;
        boys.push_back(temp);
        hash[temp] += 1;
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int temp;
        cin >> temp;
        girls.push_back(temp);
        if(hash[temp] > 0){
            ans++;
            hash[temp]--;
        }
        else if(hash[temp+1] > 0){
            ans++;
            hash[temp+1]--;
        }
        else if(hash[temp-1] >0){
            ans++;
            hash[temp-1]--;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cin >> n;
    vector<int> boys, girls;
    for(int i=0;i<n;i++){
        int temp; cin >> temp;
        boys.push_back(temp);
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int temp; cin >> temp;
        girls.push_back(temp);
    }
    sort(boys.begin(),boys.end());
    sort(girls.begin(),girls.end());
    int b = 0, g = 0, ans = 0;
    while( b<n && g<m ){
        if(abs(girls[g]-boys[b]) <= 1){
            ans++;
            g++;
            b++;
        }
        else if(girls[g] > boys[b]){
            b++;
        }
        else{
            g++;
        }
    }
    cout << ans << endl;
    return 0;
}


# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
const int nmax = 1e3 + 5;
int s[nmax],v[nmax];
int main(void)
{
    int n,m,ans=0;
    fi>>n;
    for (int i=1,x;i<=n;++i) fi>>x,++s[x];
    fi>>m;
    for (int i=1,x;i<=m;++i) fi>>x,++v[x];
    for (int i=1;i<=100;++i) if (s[i]) ans+=bool(v[i+1])+bool(v[i])+bool(v[i-1]);
    return fo << ans << '\n',0;
}


# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
const int nmax = 1e3 + 5;
int s[nmax],v[nmax];
int main(void)
{
    int n,m,ans=0;
    fi>>n;
    for (int i=1,x;i<=n;++i) fi>>x,++s[x];
    fi>>m;
    for (int i=1,x;i<=m;++i) fi>>x,++v[x];
    for (int i=1;i<=100;++i)
    {
        if (s[i] >= v[i-1]) ans+=v[i-1],s[i]-=v[i-1];else s[i]=0,ans+=s[i],v[i-1]-=s[i];
        if (s[i] >= v[i]) ans+=v[i],s[i]-=v[i];else s[i]=0,ans+=s[i],v[i]-=s[i];
        if (s[i] >= v[i+1]) ans+=v[i+1],s[i]-=v[i+1];else s[i]=0,ans+=s[i],v[i+1]-=s[i];
    }
    return fo << ans << '\n',0;
}


# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
const int nmax = 1e3 + 5;
int s[nmax],v[nmax];
int main(void)
{
    int n,m,ans=0;
    fi>>n;
    for (int i=1;i<=n;++i) fi>>s[i];
    fi>>m;
    for (int i=1;i<=m;++i) fi>>v[i];
    for (int i=1;i<=n;++i) for (int j=1;j<=m;++j) ans+=(abs(s[i]-v[j])<2);
    ans/=2;
    return fo << ans << '\n',0;
}


# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
const int nmax = 105;
int s[nmax],v[nmax];
int main(void)
{
    int n,m,ans=0;
    fi>>n;
    for (int i=1,x;i<=n;++i) fi>>x,++s[x];
    fi>>m;
    for (int i=1,x;i<=m;++i) fi>>x,++v[x];
    for (int i=1;i<=100;++i)
    {
        if (s[i] >= v[i-1]) ans+=v[i-1],s[i]-=v[i-1],v[i-1]=0;else ans+=s[i],v[i-1]-=s[i],s[i]=0;
        if (s[i] >= v[i]) ans+=v[i],s[i]-=v[i],v[i]=0;else ans+=s[i],v[i]-=s[i],s[i]=0;
        if (s[i] >= v[i+1]) ans+=v[i+1],s[i]-=v[i+1],v[i+1]=0;else ans+=s[i],v[i+1]-=s[i],s[i]=0;
    }
    return fo << ans << '\n',0;
}


#include <bits/stdc++.h>

using namespace std;

main () {
    int n;
    cin >> n;
    pair<int, int> a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    int m;
    cin >> m;
    pair <int, int> b[m];
    bool used[m];
    for (int i = 0; i < m; ++i) {
        cin >> b[i].first;
        b[i].second = i;
        used[i] = false;
    }
    sort (a, a + n);
    sort (b, b + m);
    vector <pair <int, int> > ans;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (!used[j] && abs(a[i].first - b[j].first) <= 1) {
                ans.push_back ({a[i].second, b[j].second});
                used[j] = true;
                break;
            }
        }
    }
    cout << ans.size () << "\n";
    //for (int i = 0; i < ans.size (); ++i) cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <bits/stdc++.h>

using namespace std;

main () {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int m;
    cin >> m;
    int b[m];
    bool used[m];
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        used[i] = false;
    }
    vector <pair <int, int> > ans;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (!used[j] && abs(a[i] - b[j]) <= 1) {
                ans.push_back ({i, j});
                used[j] = true;
                break;
            }
        }
    }
    cout << ans.size () << "\n";
    //for (int i = 0; i < ans.size (); ++i) cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <map>
#include <cstring>
#include <climits>
#include <deque>
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <array>
#include <queue>

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

#define FV(i,v) for (int i = 0; i < (int) (v).size(); ++i)
#define FI(i,v) for (auto i = v.begin(); i != v.end(); ++i)
#define sz(v) (uint64) (v).size()
#define all(v) (v).begin(), (v).end()
#define REP(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define FOR(i, st, en) for (int i = (st); i < (int) (en); ++i)
#define CR(v) cout << v << endl; return;

void Solve() {
    int n, m;
    vector<int> a, b;

    cin >> n;
    a.resize(n);
    FV(i, a) {
        cin >> a[i];
    }

    cin >> m;
    b.resize(m);
    FV(i, b) {
        cin >> b[i];
    }

    if (m < n) {
        swap(n, m);
        swap(a, b);
    }

    vector<int> hist(101, 0);
    FV(i, b) {
        hist[b[i]]++;
    }

    int counter = 0;
    FV(i, a) {
        int s = a[i];

        int max_num = 0;
        int max_idx = 0;
        for (int j = s - 1; (j <= s + 1) && (j <= 100); ++j) {
            if (hist[j] > max_num) {
                max_num = hist[j];
                max_idx = j;
            }
        }

        if (max_num > 0) {
            hist[max_idx]--;
            counter++;
        }
    }

    CR(counter);
}

#ifdef ONLINE_JUDGE
int main() { Solve(); return 0; }
#else
void perform_testing(void (*Solve)(), string problem, int itest);
int main() { perform_testing(Solve, "B", -1); return 0; }
#endif // ONLINE_JUDGE


#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <map>
#include <cstring>
#include <climits>
#include <deque>
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <array>
#include <queue>

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

#define FV(i,v) for (int i = 0; i < (int) (v).size(); ++i)
#define FI(i,v) for (auto i = v.begin(); i != v.end(); ++i)
#define sz(v) (uint64) (v).size()
#define all(v) (v).begin(), (v).end()
#define REP(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define FOR(i, st, en) for (int i = (st); i < (int) (en); ++i)
#define CR(v) cout << v << endl; return;

void Solve() {
    int n, m;
    vector<int> a, b;

    cin >> n;
    a.resize(n);
    FV(i, a) {
        cin >> a[i];
    }

    cin >> m;
    b.resize(m);
    FV(i, b) {
        cin >> b[i];
    }

    if (m < n) {
        swap(n, m);
        swap(a, b);
    }

    vector<int> hist(101, 0);
    FV(i, b) {
        hist[b[i]]++;
    }

    sort(all(a));

    int counter = 0;
    FV(i, a) {
        int s = a[i];

        int max_num = 0;
        int max_idx = 0;
        for (int j = s - 1; (j <= s + 1) && (j <= 100); ++j) {
            if (hist[j] > max_num) {
                max_num = hist[j];
                max_idx = j;
            }
        }

        if (max_num > 0) {
            hist[max_idx]--;
            counter++;
        }
    }

    CR(counter);
}

#ifdef ONLINE_JUDGE
int main() { Solve(); return 0; }
#else
void perform_testing(void (*Solve)(), string problem, int itest);
int main() { perform_testing(Solve, "B", -1); return 0; }
#endif // ONLINE_JUDGE


#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <map>
#include <cstring>
#include <climits>
#include <deque>
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <array>
#include <queue>

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

#define FV(i,v) for (int i = 0; i < (int) (v).size(); ++i)
#define FI(i,v) for (auto i = v.begin(); i != v.end(); ++i)
#define sz(v) (uint64) (v).size()
#define all(v) (v).begin(), (v).end()
#define REP(i,n) for (int (i) = 0; (i) < (n); ++(i))
#define FOR(i, st, en) for (int i = (st); i < (int) (en); ++i)
#define CR(v) cout << v << endl; return;

void Solve() {
    int n, m;
    vector<int> a, b;

    cin >> n;
    a.resize(n);
    FV(i, a) {
        cin >> a[i];
    }

    cin >> m;
    b.resize(m);
    FV(i, b) {
        cin >> b[i];
    }

    if (m < n) {
        swap(n, m);
        swap(a, b);
    }

    vector<int> hist(101, 0);
    FV(i, b) {
        hist[b[i]]++;
    }

    sort(all(a));

    int counter = 0;
    FV(i, a) {
        int s = a[i];

        int max_num = 0;
        int max_idx = 0;
        for (int j = s - 1; (j <= s + 1) && (j <= 100); ++j) {
            if (hist[j] > 0) {
                hist[j]--;
                counter++;
                break;
            }
        }
    }

    CR(counter);
}

#ifdef ONLINE_JUDGE
int main() { Solve(); return 0; }
#else
void perform_testing(void (*Solve)(), string problem, int itest);
int main() { perform_testing(Solve, "B", -1); return 0; }
#endif // ONLINE_JUDGE


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int n, m, arr1[110], arr2[110], dp[110][110];

int solve(int i, int j){
    if(i == n || j == m) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    int ans = 0;
    for(int s=j ; s<m ; s++){
        if(abs(arr1[i] - arr2[s]) <= 1){
            ans = max(ans , 1+solve(i+1, s+1));
        }
    }
    return dp[i][j] = ans;
}

int main() {
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++) scanf("%d", &arr1[i]);

    sort(arr1, arr1+n);

    scanf("%d", &m);
    for(int i=0 ; i<m ; i++) scanf("%d", &arr2[i]);

    sort(arr2, arr2+m);

    memset(dp, -1 , sizeof dp);

    int Max = 0;
    for(int i=0 ; i<n ; i++){
        Max = max(Max, solve(i,0));
    }
    printf("%d\n" , Max);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int n, m, arr1[110], arr2[110], dp[110][110];

int solve(int i, int j){
    if(i == n || j == m) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    int ans = 0;
    for(int s=j ; s<m ; s++){
        if(abs(arr1[i] - arr2[s]) <= 1){
            ans = max(ans , 1+solve(i+1, s+1));
        }
        if(arr2[s] - arr1[i] > 1) break;
    }

    ans = max(ans, solve(i+1,j));
    return dp[i][j] = ans;
}

int main() {
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++) scanf("%d", &arr1[i]);

    sort(arr1, arr1+n);

    scanf("%d", &m);
    for(int i=0 ; i<m ; i++) scanf("%d", &arr2[i]);

    sort(arr2, arr2+m);

    memset(dp, -1 , sizeof dp);

    int Max = 0;
    for(int i=0 ; i<n ; i++){
        Max = max(Max, solve(i,0));
    }
    printf("%d\n" , Max);
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
    int n, m, arr1[110], arr2[110];
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++) scanf("%d", &arr1[i]);

    sort(arr1, arr1+n);

    scanf("%d", &m);
    for(int i=0 ; i<m ; i++) scanf("%d", &arr2[i]);

    sort(arr2, arr2+m);

    int st = 0, Max = -1;
    while(st < n){
        int ans = 0;
        for(int i=st, j=0 ; i<n && j<m ; j++){
            if( abs(arr1[i] - arr2[j]) <= 1) ans++, i++;
        }
        Max = max(Max, ans);
        st++;
    }

    st = 0;
    while(st < n){
        int ans = 0;
        for(int j=st, i=0 ; i<n && j<m ; i++){
            if( abs(arr1[i] - arr2[j]) <= 1) ans++, j++;
        }
        Max = max(Max, ans);
        st++;
    }

    printf("%d\n" , Max);

    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
    int n, m, arr1[110], arr2[110], dp[110][110];
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++) scanf("%d", &arr1[i]);

    sort(arr1, arr1+n);

    scanf("%d", &m);
    for(int i=0 ; i<m ; i++) scanf("%d", &arr2[i]);

    sort(arr2, arr2+m);

    memset(dp, 0 , sizeof dp);

    for(int i=n-1 ; i>=0; i--){
        for(int j=m-1; j>=0 ; j--){
            for(int s = j; s < m ; s++){
                if(abs(arr1[i] - arr2[s]) <= 1){
                    dp[i][j] = max(dp[i][j], 1 + dp[i+1][s+1]);
                }
            }
        }
    }

    int Max = -1;
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<m ; j++){
            Max = max(Max, dp[i][j]);
        }
    }

    printf("%d\n" , Max);
    return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int main()
{
   vector<int>boys;
   vector<int>girls;
   int x , b , g , sum=0 ;
   cin >> b ;
   for (int i = 0 ; i<b ; i++ )
   {
       cin >> x ;
       boys.push_back(x);
   }
   cin >> g ;
   for (int i = 0 ; i<g ; i++ )
   {
       cin >> x ;
       for (int j =0 ; j<boys.size() ; j++)
       {
           if (abs(x-boys[j])<=1){sum++; boys.erase(boys.begin() + j); break ;}
       }
   }
  cout<<sum;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
   vector<int>boys;
   vector<int>girls;
   int x , b , g , sum=0 ;
   cin >> b ;
   for (int i = 0 ; i<b ; i++ )
   {
       cin >> x ;
       boys.push_back(x);
   }
   cin >> g ;
   for (int i = 0 ; i<g ; i++ )
   {
       cin >> x ;
       girls.push_back(x);
   }
   sort(boys.begin() ,boys.end());
   sort(girls.begin(), girls.end());
   for (int i = 0 ; i<g ; i++ ){
       for (int j =0 ; j<boys.size() ; j++)
       {
           if (abs(girls[i]-boys[j])<=1){sum++; boys.erase(boys.begin() + j); break ;}
       }
   }
  cout<<sum;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <set>
#include <vector>
#include <utility>

using namespace std;

#define MAX 100

typedef long long ll;
typedef pair<int, int> pii;

int n, m;
int sn[MAX], sm[MAX];

bool match(int l, int r)
{
    return (r - l) <= 1 && (l - r) <= 1;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL

    cin >> n;
    for (int i = 0; i < n; i++) cin >> sn[i];
    cin >> m;
    for (int i = 0; i < m; i++) cin >> sm[i];

    sort(sn, sn + n);
    sort(sm, sm + m);

//    for (int i = 0; i < n; i++) cout << sn[i] << " ";
//    cout << endl;
//    for (int i = 0; i < m; i++) cout << sm[i] << " ";
//    cout << endl;

    int matches = 0;

    int lp = 0, rp = 0;
    while (lp < n && rp < m) {
        if (match(sn[lp], sm[rp])) {
            matches++;
            lp++;
            rp++;
        } else if (sn[lp] < sm[rp]) {
            while (lp < n && sn[lp] < sm[rp] - 1) {
                lp++;
            }
        } else {
            while (rp < n && sm[rp] < sn[lp] - 1) {
                rp++;
            }
        }
    }
    cout << matches << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <set>
#include <vector>
#include <utility>

using namespace std;

#define MAX 100

typedef long long ll;
typedef pair<int, int> pii;

int n, m;
int sn[MAX], sm[MAX];

bool match(int l, int r)
{
    return (r - l) <= 1 && (l - r) <= 1;
}

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL

    cin >> n;
    for (int i = 0; i < n; i++) cin >> sn[i];
    cin >> m;
    for (int i = 0; i < m; i++) cin >> sm[i];

    sort(sn, sn + n);
    sort(sm, sm + m);

//    for (int i = 0; i < n; i++) cout << sn[i] << " ";
//    cout << endl;
//    for (int i = 0; i < m; i++) cout << sm[i] << " ";
//    cout << endl;

    int matches = 0;

    int lp = 0, rp = 0;
    while (lp < n && rp < m) {
        // cerr << lp << ", " << rp << endl;
        if (match(sn[lp], sm[rp])) {
            matches++;
            lp++;
            rp++;
        } else if (sn[lp] < sm[rp]) {
            while (lp < n && sn[lp] < sm[rp] - 1) {
                lp++;
            }
        } else {
            while (rp < m && sm[rp] < sn[lp] - 1) {
                rp++;
            }
        }
    }
    cout << matches << endl;
    return 0;
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <cstdio>
#include <assert.h>

using namespace std;

#define pb push_back
#define INF 1011111111
#define FOR(i, a, b) for (int _n(b), i(a); i < _n; i++)
#define rep(i, n) FOR(i, 0, n)
#define CL(a, v) memset((a), (v), sizeof(a))
#define mp make_pair
#define X first
#define Y second
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;

/*** TEMPLATE CODE ENDS HERE */

int main() {
#ifdef LOCAL_HOST
  freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif

  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n;
  VI a(n);
  for (int &x : a) cin >> x;
  cin >> m;
  VI b(m);
  for (int &x : b) cin >> x;

  SORT(a);
  SORT(b);
  int ans = 0;
  for (int i = 0, j = 0; i < n && j < m;) {
    if (abs(a[i] - b[j]) <= 1) {
      ++ans;
      ++i;
      ++j;
    } else if (a[i] < b[j]) {
      ++i;
    } else if (a[i] > b[j]) {
      ++j;
    }
  }
  cout << ans << endl;

#ifdef LOCAL_HOST
  printf("TIME: %.3lf\n", double(clock()) / CLOCKS_PER_SEC);
#endif

  return 0;
}


#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <iostream>
#include <cmath>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <memory.h>
#include <cstdio>
#include <assert.h>

using namespace std;

#define pb push_back
#define INF 1011111111
#define FOR(i, a, b) for (int _n(b), i(a); i < _n; i++)
#define rep(i, n) FOR(i, 0, n)
#define CL(a, v) memset((a), (v), sizeof(a))
#define mp make_pair
#define X first
#define Y second
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))

typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;

/*** TEMPLATE CODE ENDS HERE */

int main() {
#ifdef LOCAL_HOST
  freopen("input.txt", "r", stdin);
// freopen("output.txt","w",stdout);
#endif

  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n;
  VI a(n);
  for (int &x : a) cin >> x;
  cin >> m;
  VI b(m);
  for (int &x : b) cin >> x;

  SORT(a);
  SORT(b);
  int ans = 0;
  for (int i = 0, j = 0; i < n && j < m;) {
    if (abs(a[i] - b[j]) <= 1) {
      ++ans;
      ++i;
      ++j;
    }
    if (a[i] < b[j]) {
      ++i;
    }
    if (a[i] > b[j]) {
      ++j;
    }
  }
  cout << ans << endl;

#ifdef LOCAL_HOST
  printf("TIME: %.3lf\n", double(clock()) / CLOCKS_PER_SEC);
#endif

  return 0;
}


#include "algorithm"
#include "iostream"

using namespace std;
int main(int argc, char *argv[])
{
  int n,m,boys[100],girls[100];
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin>>boys[i];
  }
  cin>>m;
  for (int i = 0; i < m; i++) {
    cin>>girls[i];
  }
  sort(boys,boys+n);
  sort(girls,girls+m);
  int result=0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (abs(boys[i]-girls[j])<=1){
	result++;
	girls[j]=1000;
	break;
      }
    }
  }
  cout<<result;

  return 0;
}


#include "algorithm"
#include "vector"
#include "iostream"

using namespace std;
int main(int argc, char *argv[])
{
  int n,m,tmp;
  cin>>n;
  vector<int> boys;
  for (int i = 0; i < n; i++) {
    cin>>tmp;
    boys.push_back(tmp);
  }
  cin>>m;
  vector<int> girls;
  for (int i = 0; i < m; i++) {
    cin>>tmp;
    girls.push_back(tmp);
  }
  int result=0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (abs(boys[i]-girls[j])<=1){
	result++;
	girls[j]=1000;
	break;
      }
    }
  }
  cout<<result;

  return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

    int n , m , a[300] , b[300] , ans;
main(){

            cin >> n;
            for(int i = 0 ; i < n ; ++i) cin >> a[i];
            cin >> m;
            for(int i = 0 ; i < m ; ++i) cin >> b[i];
            sort(a , a + n);
            sort(b , b + m);
            int l = 0 , r = -1;
            while(l < n){

                if(abs(b[r+1] - a[l]) < 2 && r < n) ++l , ++r , ++ans;
                else if(b[r+1] < a[l]) ++r; else ++l;

            }
            cout << ans;

}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

    int n , m , a[300] , b[300] , ans;
main(){

            cin >> n;
            for(int i = 0 ; i < n ; ++i) cin >> a[i];
            cin >> m;
            for(int i = 0 ; i < m ; ++i) cin >> b[i];
            sort(a , a + n);
            sort(b , b + m);
            int l = 0 , r = -1;
            while(l < n){

                if(abs(b[r+1] - a[l]) < 2 && r < m) ++l , ++r , ++ans;
                else if(b[r+1] < a[l]) ++r; else ++l;

            }
            cout << ans;

}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

    int n , m , a[300] , b[300] , ans;
main(){

            cin >> n;
            for(int i = 0 ; i < n ; ++i) cin >> a[i];
            cin >> m;
            for(int i = 0 ; i < m ; ++i) cin >> b[i];
            sort(a , a + n);
            sort(b , b + m);
            int l = 0 , r = -1;
            while(l < n){

                if(abs(b[r+1] - a[l]) < 2 && r < n) ++r , ++ans;
                ++l;

            }
            cout << ans;

}


// Kenzhaliev
#include <bits/stdc++.h>
using namespace std;
int n, i, j, a[110], b[110], used[110], m, ans;
int main() {
    scanf("%d", &n);
    for(i = 0; i < n; i ++) scanf("%d", a + i); scanf("%d", &m);
    for(i = 0; i < m; i ++) scanf("%d", b + i); sort(a, a + n); sort(b, b + m);
    for(i = 0; i < n; i ++){
        for(j = 0; j < m; j ++){
            if(!used[j] && abs(a[i] - b[j]) <= 1){
                used[j] = true, ans ++;
                break;
            }
        }
    }
    printf("%d", ans);
}


// Kenzhaliev
#include <bits/stdc++.h>
using namespace std;
int n, i, j, a[110], b[110], used[110], m, ans;
int main() {
    scanf("%d", &n);
    for(i = 0; i < n; i ++) scanf("%d", a + i); scanf("%d", &m);
    for(i = 0; i < m; i ++) scanf("%d", b + i);
    for(i = 0; i < n; i ++){
        for(j = 0; j < m; j ++){
            if(!used[j] && abs(a[i] - b[j]) <= 1){
                used[j] = true, ans ++;
                break;
            }
        }
    }
    printf("%d", ans);
}


#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

#define NONE -1

int n, m, boys[100], girls[100], br = 0, temp;

void inAll()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &boys[i]);
    sort(boys, boys + n);
    scanf("%d", &m);
    for (int i = 0; i < m; i ++)
        scanf("%d", &girls[i]);
    sort(girls, girls + m);
}

int getAnswer()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        if (fabs(boys[i] - girls[j]) <= 1 && girls[i] != NONE)
        {
            girls[j] = NONE;
            br++;
            break;
        }

    }
    printf("%d\n",br);
}

int main()
{
    inAll();
    getAnswer();
}


#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

#define NONE -1

int n, m, boys[100], girls[100], br = 0, temp;

void inAll()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &boys[i]);
    sort(boys, boys + n);
    scanf("%d", &m);
    for (int i = 0; i < m; i ++)
        scanf("%d", &girls[i]);
    sort(girls, girls + m);
}

int getAnswer()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++){
        if ((fabs(boys[i] - girls[j]) <= 1) &&( girls[j] != NONE))
        {
            girls[j] = NONE;
            br++;
            break;
        }
        };//for (int j = 0; j < m; j++)printf("%d\n", girls[j]);
    }
   // for (int j = 0; j < m; j++) printf("%d\n", girls[j]);
    printf("%d\n",br);
}

int main()
{
    inAll();
    getAnswer();
}


#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

#define NONE -1

int n, m, boys[100], girls[100], br = 0, temp;

void inAll()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &boys[i]);
    sort(boys, boys + n);
    scanf("%d", &m);
    for (int i = 0; i < m; i ++)
        scanf("%d", &girls[i]);
    sort(girls, girls + m);
}

int getAnswer()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        if (fabs(boys[i] - girls[j]) <= 1 && girls[i] != NONE)
        {
            girls[j] = NONE;
            br++;
        }

    }
    printf("%d\n",br);
}

int main()
{
    inAll();
    getAnswer();
}


#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;

#define NONE -1

int n, m, boys[100], girls[100], br = 0, temp;

void inAll()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i ++)
        scanf("%d", &boys[i]);
    sort(boys, boys + n);
    scanf("%d", &m);
    for (int i = 0; i < m; i ++)
        scanf("%d", &girls[i]);
    sort(girls, girls + m);
}

int getAnswer()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        if (fabs(boys[i] - girls[j]) <= 1 && girls[i] != NONE)
        {
            girls[i] = NONE;
            br++;
        }

    }
    printf("%d\n",br);
}

int main()
{
    inAll();
    getAnswer();
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int a[107];
int b[107];
int w[107][107];
int n, m;

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	cin >> m;
	for(int i = 1; i <= m; ++i) cin >> b[i];

	sort(a + 1, a + n + 1);
	sort(b + 1, b + m + 1);
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
		{
			w[i][j] = max(w[i - 1][j], w[i][j - 1]);
			if(abs(a[i] - b[j]) <= 1) w[i][j] = max(w[i][j], w[i - 1][j - 1] + 1);
		}
	}

	cout<< w[n][m] << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int a[107];
int b[107];
int n, m;

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	cin >> m;
	for(int i = 0; i < m; ++i) cin >> b[i];

	sort(a, a + n);
	sort(b, b + m);

	int wynik = 0;

	int j = 0;
	for(int i = 0; i < n; ++i)
	{
		for(int z = j; z < m; ++z)
		{
			if(abs(a[i] - b[z]) <= 1)
			{
				j = z + 1;
				wynik++;
				break;
			}
			if(b[z] > a[i] + 1) break;
		}
	}
	cout << wynik << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define INF 1000000000

int n, m;
int a[107];
int b[107];
VI g[207];
int odw[207];
int skoj[207];

bool DFS(int v)
{
	odw[v] = 1;
	REP(i, (int) g[v].size())
	{
		int x = g[v][i];
		if(skoj[x] == -1 || (!odw[skoj[x]] && DFS(skoj[x])))
		{
			skoj[x] = v;
			skoj[v] = x;
			return true;
		}
	}
	return false;
}

void turbomaczing()
{
	FOR(i, 1, n + m) skoj[i] = -1;
	bool st = 1;
	while(st)
	{
		st = false;
		FOR(i, 1, n) odw[i] = false;
		FOR(i, 1, n) if(!odw[i] && skoj[i] == -1) st |= DFS(i);
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n; FOR(i, 1, n) cin >> a[i];
	cin >> m; FOR(i, 1, m) cin >> b[i];

	FOR(i, 1, n)
	{
		FOR(j, 1, m)
		{
			if(abs(a[i] - b[j]) <= 1)
			{
				g[i].push_back(j + n);
				g[j + n].push_back(i);
			}
		}
	}

	turbomaczing();

	int w = 0;
	FOR(i, 1, n) if(skoj[i] != -1) w++;
	cout << w << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> VI;
typedef pair<int, int> PII;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define INF 1000000000

int n, m;
int a[107];
int b[107];
VI g[207];
int odw[107];
int skoj[107];

bool DFS(int v)
{
	odw[v] = 1;
	REP(i, (int) g[v].size())
	{
		int x = g[v][i];
		if(skoj[x] == -1 || (!odw[skoj[x]] && DFS(skoj[x])))
		{
			skoj[x] = v;
			skoj[v] = x;
			return true;
		}
	}
	return false;
}

void turbomaczing()
{
	FOR(i, 1, n + m) skoj[i] = -1;
	bool st = 1;
	while(st)
	{
		st = false;
		FOR(i, 1, n) odw[i] = false;
		FOR(i, 1, n) if(!odw[i] && skoj[i] == -1) st |= DFS(i);
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n; FOR(i, 1, n) cin >> a[i];
	cin >> m; FOR(i, 1, m) cin >> b[i];

	FOR(i, 1, n)
	{
		FOR(j, 1, m)
		{
			if(abs(a[i] - b[j]) <= 1)
			{
				g[i].push_back(j + n);
				g[j + n].push_back(i);
			}
		}
	}

	turbomaczing();

	int w = 0;
	FOR(i, 1, n) if(skoj[i] != -1) w++;
	cout << w << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int a[107];
int b[107];
int w[107][107];
int n, m;

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	cin >> m;
	for(int i = 1; i <= m; ++i) cin >> b[i];

	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
		{
			w[i][j] = max(w[i - 1][j], w[i][j - 1]);
			if(abs(a[i] - b[j]) <= 1) w[i][j] = max(w[i][j], w[i - 1][j - 1] + 1);
		}
	}

	cout<< w[n][m] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[105],b[105],cnt=0;
vector<int> v;
vector<int>::iterator it;
int main() {
     int n,m;
     cin>>n;
     for(int i=0;i<n;i++){
        cin>>a[i];
     }
     cin>>m;
     for(int i=0;i<m;i++)cin>>b[i];
     for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(abs(a[i]-b[j])<=1){
             it = find (v.begin(), v.end(),j);
             if(it == v.end()){
                cnt++;
                v.push_back(j);
                break;
             }
          }
        }
     }
     cout<<cnt;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[105],b[105],cnt=0;
vector<int> v;
vector<int>::iterator it;
int main() {
     int n,m;
     cin>>n;
     for(int i=0;i<n;i++)
        cin>>a[i];
     cin>>m;
     for(int i=0;i<m;i++)cin>>b[i];
     for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(abs(a[i]-b[j])<=1){
             it = find (v.begin(), v.end(),j);
             if(it == v.end()){
                cnt++;
                v.push_back(j);
                break;
             }
          }
        }
     }
     cout<<cnt;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[105],b[105],cnt=0;
vector<int> v;
vector<int>::iterator it;
int main() {
     int n,m;
     cin>>n;
     for(int i=0;i<n;i++)
        cin>>a[i];
     cin>>m;
     for(int i=0;i<m;i++)cin>>b[i];
     sort(a,a+n);
     sort(b,b+m);
     for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(abs(a[i]-b[j])<=1){
             it = find (v.begin(), v.end(),j);
             if(it == v.end()){
                cnt++;
                v.push_back(j);
                break;
             }
          }
        }
     }
     cout<<cnt;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <numeric>
#include <cassert>
#include <random>
#include <stdarg.h>
#include <string.h>
#include <stack>
#include <string>
#include <map>
#include <stdio.h>
#include <fstream>
#include <limits.h>
#include <set>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <functional>
#include <deque>
#include <queue>
#include <stdlib.h>

#define int long long int
bool RANDOM = false;

#define DEBUG
#define NULL 0

#include <iostream>
#include <vector>
using namespace std;

double EPS = 0.0000000001;
double INF = 1000000000000000.0;

ostream_iterator<int> oi(cout, " ");

int minInt = 1;
int maxInt = 1;
double minDouble = -100000000000.0;
double maxDouble = 100000000000.0;

void setMaxInt(int newMax){
    maxInt = newMax;
}

void setMinInt(int newMin){
    minInt = newMin;
}

void setIntRange(int min, int max){
    maxInt = max;
    minInt = min;
}

void setMaxDouble(double newMax){
    maxDouble = newMax;
}

void setMinDouble(double newMin){
    minDouble = newMin;
}

void setDoubleRange(double min, double max){
    maxDouble = max;
    minDouble = min;
}

ostream & operator<<( ostream & out, pair<int, int>& c  )
{
    out << "<" <<c.first << ", ";
    out << c.second << ">" << endl;
    return out;
}

void print()
{
    std::cout << endl;
}

template<typename A>
void print(A value)
{
    std::cout << value;
}

template<typename A, typename B>
void print(A value1, B value2)
{
    cout << value1 << " " << value2;
}

template<typename A, typename B, typename C>
void print(A value1, B value2, C value3)
{
    cout << value1 << " " << value2 << " " << value3;
}

template<typename A, typename B, typename C, typename D>
void print(A value1, B value2, C value3, D value4)
{
    cout << value1 << " " << value2 << " " << value3 << " " << value4;
}

template<typename A>
void println(A value)
{
    std::cout << value << endl;
}

template<typename A, typename B>
void println(A value1, B value2)
{
    cout << value1 << " " << value2 << endl;
}

template<typename A, typename B, typename C>
void println(A value1, B value2, C value3)
{
    cout << value1 << " " << value2 << " " << value3 << endl;
}

template<typename A, typename B, typename C, typename D>
void println(A value1, B value2, C value3, D value4)
{
    cout << value1 << " " << value2 << " " << value3 << " " << value4 << endl;
}

int randomint(int min, int max)
{
    return rand()%(max-min+1)+min;
}

double randomdouble(double min, double max)
{
    return (rand() / (double)RAND_MAX) * (max - min) + min;
}

template<typename E>
E read(){
    E value;
    cin >> value;
    return value;
}

template<>
int read<int>()
{
    if(!RANDOM) {
        int value;
        cin >> value;
        return value;
    } else {
        return randomint(minInt, maxInt);
    }
}

template<>
double read<double>()
{
    if(!RANDOM) {
        double value;
        cin >> value;
        return value;
    } else {
        return randomdouble(minDouble, maxDouble);
    }
}

/*
template<typename T>
Array<T> read<Array<T> >()
{
    int n = read<int>();
    Array<T> res(n);
    cin >> res;
    retrun res;
}
*/

istream& operator>>(istream& in, pair<int, int>& c)
{
    c.first = read<int>();
    c.second = read<int>();
    return in;
}

ostream& operator<<( ostream & out, string& c)
{
    for(int i = 0; i<c.length(); i++) {
        putchar(c[i]);
    }
    return out;
}

template<typename E>
class Array
{
public:
    int size;
    Array<E>(int _capacity) {
        capacity = _capacity;
        array = new E[capacity];
        size = capacity;
        fill();
    }

    void sort() {
        std::sort(&array[0], &array[size]);
    }

    Array() {
        capacity = 4;
        array = new E[capacity];
        size = 0;
    }

    Array(vector<E>& vect) {
        int _size = vect.size();
        capacity = _size*2;
        size = _size;
        array = new E[capacity];
        for(int i =0; i<size; i++) {
            array[i] = vect[i];
        }
    }

    Array(int minBound, int maxBound, int _size) {
        srand(_size);
        capacity = _size*2;
        size = _size;
        array = new E[capacity];
        for(int i = 0; i<size; i++) {
            array[i] = randomint(minBound, maxBound);
        }
    }

    void add(E item);
    int leftBinarySearch(E& item);
    int rightBinarySearch(E& item);
    pair<int, int> equalRange(E& item);
    bool binarySearch(E& item);
    void fill();
    E* begin();
    E* end();
    vector<E> toVector();
    void toString(ostream& stream);
    E& operator[](int i);
    E& index(int i);
    E* array;
private:
    int capacity;
    void ensureCapacity(int cap);
};

template <typename E>
void Array<E>::ensureCapacity(int cap)
{
    capacity = capacity*2;
    E* newArray = new E[capacity];
    memcpy(newArray, array, sizeof(E)*size);
    delete[] array;
    array = newArray;
}

template <typename E>
void Array<E>::fill()
{
    for(int i = 0; i<size; i++) {
        array[i] = NULL;
    }
}

template <>
void Array<pair<int, int> >::fill()
{
    for(int i = 0; i<size; i++) {
        array[i] = make_pair(0, 0);
    }
}

template <>
void Array<string>::fill()
{
    for(int i = 0; i<size; i++) {
        array[i] = "";
    }
}

template <typename E>
void Array<E>::toString(ostream& stream)
{
    int i = 0;
    while(i<size) {
        if(i == size-1) {
            stream << array[i];
        } else {
            stream << array[i] << " ";
        }
        i++;
    }
    stream << endl;
}

template <typename E>
void Array<E>::add(E item)
{
    if(capacity<size+1) {
        ensureCapacity(size+1);
    }
    array[size] = item;
    size++;
}

template <typename E>
E* Array<E>::begin()
{
    return array;
}

template <typename E>
E* Array<E>::end()
{
    return array + size;
}

template <typename E>
int Array<E>::leftBinarySearch(E& item)
{
    return lower_bound(array, array+size, item)-array;
}

template <typename E>
int Array<E>::rightBinarySearch(E& item)
{
    return upper_bound(array, array+size, item)-array;
}

template <typename E>
pair<int, int> Array<E>::equalRange(E& item)
{
    pair<int*, int*> p(0, 0);
    p = equal_range(array, array + size, item);
    return make_pair(p.first - array, p.second - array);
}

template <typename E>
bool Array<E>::binarySearch(E& item)
{
    return binary_search(array, array + size, item);
}

template <typename E>
vector<E> Array<E>::toVector()
{
    vector<E> res = vector<E>(size);
    for(int i =0; i<res.size(); i++) {
        res[i] = array[i];
    }
    return res;
}

template<typename T>
ostream & operator<<( ostream& out, Array<T>& c  )
{
    c.toString(out);
    return out;
}

ostream & operator<<( ostream & out, Array< pair<int, int> >& c  )
{
    for(int i = 0; i<c.size; i++) {
        out << c[i];
    }
    return out;
}

template<typename T>
istream& operator>>(istream& in, Array<T>& c  )
{
    for(int i = 0; i<c.size; i++) {
        c[i] = read<T>();
    }
    return in;
}

ostream& operator<<(ostream& out, map<int, int>& c  )
{
    map<int, int>::iterator it = c.begin();
    while(it!=c.end()) {
        pair<int, int> entry = *it;
        out << entry;
        it++;
    }
    return out;
}

Array<pair<int , int> > mapToArray(map<int, int>& c)
{
    Array<pair<int, int> > res(c.size());
    map<int, int>::iterator it = c.begin();
    int i = 0;
    while(it!=c.end()) {
        pair<int, int> entry = *it;
        res[i] = entry;
        i++;
        it++;
    }
    return res;
}

template <typename E>
E& Array<E>::operator[] (int i)
{
#ifdef DEBUG
    if(i<size && i>=0) {
        return array[i];
    } else {
        cout << "Array index out of bounds, index is " << i << ", size is " << size << endl;
        cout << "Array is " << endl;
        toString(cout);
        assert(0);
    }
#endif

#ifndef DEBUG
    return array[i]
#endif
}

template<typename E>
class Matrix
{
public:
    int rows;
    int columns;
    Array<E> array;

    E& get(int x, int y);
    void set(int x, int y, E& value);
    E& operator()(int x, int y);
    Matrix<E> transpose();

    pair<E*, E*> getRow(int y);

    Matrix<E>(int c, int r) {
        rows = r;
        columns = c;
        array = Array<E>(rows*columns);
        array.fill();
    }

    void swap(Matrix<E>& other) {
        std::swap(array, other.array);
        std::swap(rows, other.rows);
        std::swap(columns, other.columns);
    }

    Matrix<E>(int _columns, int _rows, int minBound, int maxBound) {
        rows = _rows;
        columns = _columns;
        int size = _rows*_columns;
        array = Array<E>(minBound, maxBound, size);
    }

private:
};

template<typename E>
Matrix<E> Matrix<E>::transpose()
{
    Matrix<int> b(rows, columns);
    for(int x = 0; x<columns; x++) {
        for(int y = 0; y<rows; y++) {
            b(y, x) = array.array[x+y*columns];
        }
    }
    return b;
}

template <typename E>
E& Matrix<E>::operator()(int x, int y)
{
#ifdef DEBUG
    if(x>=columns || x<0) {
        cout << "x must be in range [0; " << columns - 1 << "], but it is " << x << endl;
        assert(0);
    }
    if(y>=rows || y<0) {
        cout << "y must be in range [0; " << rows - 1 << "], but it is " << y << endl;
        assert(0);
    }
    return array.array[x+y*columns];
#endif
#ifndef DEBUG
    return array.array[x+y*columns];
#endif
}

template<typename T>
istream & operator>>(istream& in, Matrix<T>& c  )
{
    for(int y = 0; y<c.rows; y++) {
        for(int x = 0; x<c.columns; x++) {
            c(x, y) = read<T>();
        }
    }
    return in;
}

template<typename E>
pair<E*, E*> Matrix<E>::getRow(int y)
{
    E* f = array.array + y*columns;
    E* s = array.array + (y+1)*columns;
    pair<E*, E*> p(f, s);
    return p;
}

template<typename T>
ostream & operator<<( ostream & out, Matrix<T>& c  )
{
    for(size_t y = 0; y<c.rows; y++) {
        for(size_t x = 0; x<c.columns; x++) {
            out << c(x, y) << " ";
        }
        out << endl;
    }
}

class Point
{
public:
    double x;
    double y;
    Point(double _x, double _y) {
        x = _x;
        y = _y;
    }

    Point() {
        x = 0;
        y = 0;
    }
};

double dist(Point& a, Point& b)
{
    double dx = a.x-b.x;
    double dy = a.y-b.y;
    return sqrt(dx*dx+dy*dy);
}

bool cmp(double a, double b)
{
    if(fabs(a-b) < EPS) {
        return true;
    } else {
        return false;
    }
}

class Triangle
{
public:
    Point A;
    Point B;
    Point C;

    double a;
    double b;
    double c;

    Triangle(Point _A, Point _B, Point _C) {
        A = _A;
        B = _B;
        C = _C;
        a = dist(C, B);
        b = dist(C, A);
        c = dist(A, B);
    }

    Triangle() {
    }

    double S() {
        return fabs((B.x - A.x)*(C.y - A.y)-(C.x-A.x)*(B.y-A.y));
    }
};

class Line
{
public:
    double A;
    double B;
    double C;

    double xmin;
    double xmax;

    Line(Point _A, Point _B, bool isSegment) {
        set(_A, _B, isSegment);
    }

    void set(Point _A, Point _B, bool isSegment) {
        if(isSegment) {
            xmin = min(_A.x, _B.x);
            xmax = max(_A.x, _B.x);
        } else {
            xmin = -INF;
            xmax = INF;
        }

        double k = (_B.y - _A.y)/(_B.x - _A.x);
        double b = _A.y - k*_A.x;

        //printf("%lf\n", b);

        A = k;
        B = -1.0;
        C = b;
    }

    void setSegment(Point _A, Point _B) {
        set(_A, _B, true);
    }

    void setLine(Point _A, Point _B) {
        set(_A, _B, false);
    }

    double getY(double x) {
        return A*x+C;
    }

    double length() {
        double x1 = xmin;
        double y1 = getY(xmin);
        double x2 = xmax;
        double y2 = getY(xmax);
        return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
    }

    int part(Point p) {
        if(fabs(A) > 100000000.0) {
            if(cmp(p.x, xmin)) {
                return 0;
            }

            if(p.x > xmin) {
                return 1;
            } else {
                return -1;
            }
        }

        if(cmp(A*p.x + B*p.y + C, 0.0)) {
            return 0;
        }

        if(A*p.x + B*p.y + C > 0) {
            return 1;
        }

        if(A*p.x + B*p.y + C < 0) {
            return -1;
        }
    }
};

istream& operator>>(istream& in, Point& c)
{
    c.x = read<int>();
    c.y = read<int>();
}

ostream& operator<<(ostream& out, Point& c)
{
    out << "[" << c.x << ", " << c.y << "]" << endl;
}

istream& operator>>(istream& in, Triangle& c)
{
    in >> c.A;
    in >> c.B;
    in >> c.C;
}

ostream& operator<<(ostream& out, Triangle& c)
{
    out << c.A;
    out << c.B;
    out << c.C;
}

istream& operator>>( istream& in, Line& c)
{
    Point a;
    Point b;
    in >> a;
    in >> b;
    c.setLine(a, b);
}

ostream& operator<<( ostream& out, Line& c)
{
    cout << "y = " << c.A << "*x + " << c.C;
}

int bpow(int a, int b)
{
    if(b == 0) {
        return 1;
    } else {
        if(b%2 == 0) {
            int half = bpow(a, b/2);
            return half*half;
        } else {
            return bpow(a, b-1)*a;
        }
    }
}

int fact(int n)
{
    if(n == 1) {
        return 1;
    } else {
        return n*fact(n-1);
    }
}

int gcd(int a, int b)
{
    if(!b) {
        return a;
    } else {
        return gcd(b, a%b);
    }
}

Array<pair<int, int> > factorize(int n)
{
    Array<pair<int, int> > res;
    for(int i = 2; i<sqrt((double)n)+1; i++) {
        if(n%i == 0) {
            pair<int, int> comp = make_pair(i, 1);
            n/=i;
            while(n%i == 0) {
                comp.second++;
                n/=i;
            }
            res.add(comp);
        }
    }

    if(n>1) {
        res.add(make_pair(n, 1));
    }
    return res;
}

int euler(int n)
{
    Array<pair<int, int> > fact = factorize(n);
    int res = 1;
    for(unsigned int i = 0; i<fact.size; i++) {
        int factor = pow((double)fact[i].first, (double)fact[i].second)-pow((double)fact[i].first, (double)fact[i].second-1);
        res*=factor;
    }
    return res;
}

int inversePrime(int a, int m)
{
    return bpow(a, m-2)%m;
}

int inverseCoprimes(int a, int m)
{
    return bpow(a, euler(m)-1)%m;
}

int inverse(int a, int m)
{
    if(gcd(a, m) == 1) {
        return inverseCoprimes(a, m);
    } else {
        assert(0);
        return -1;
    }
}

Array<int> enumerateDivisors(int n)
{
    Array<pair<int, int> > divs = factorize(n);
    vector<int> totals = vector<int>(divs.size+1);
    totals[0] = 1;
    for(unsigned int i = 1; i < divs.size+1; i++) {
        totals[i]=totals[i-1]*(divs[i-1].second+1);
    }

    Array<int> res;
    for(int i = 0; i<totals[totals.size()-1]; i++) {
        vector<int> values = vector<int>(divs.size);
        for(unsigned int j = 0; j<values.size(); j++) {
            values[j] = (i/totals[j])%(divs[j].second+1);
        }
        int r = 1;
        for(unsigned int i = 0; i<values.size(); i++) {
            r*=bpow(divs[i].first, values[i]);
        }
        res.add(r);
    }
    return res;
}

void reverse(char *str)
{
    char temp;
    size_t len = strlen(str) - 1;
    size_t i;
    size_t k = len;

    for(i = 0; i < len; i++) {
        temp = str[k];
        str[k] = str[i];
        str[i] = temp;
        k--;
        if(k == (len / 2)) {
            break;
        }
    }
}

map<int, int> count(Array<int> a)
{
    map<int, int> res;
    for(int i = 0; i<a.size; i++) {
        res[a[i]]++;
    }
    return res;
}

void itoa(int n, char s[])
{
    int radix = 10;
    int i, sign;

    if ((sign = n) < 0)
        n = -n;
    i = 0;
    do {
        s[i++] = n % radix + '0';
    } while ((n /= radix) > 0);
    if (sign < 0)
        s[i++] = '-';
    s[i] = '\0';
    reverse(s);
}

int* vectorToArray(vector<int> v)
{
    int* a = new int[v.size()];
    for(unsigned int i = 0; i<v.size(); i++) {
        a[i] = v[i];
    }
    return a;
}

char* stringToNumber(int number)
{
    char* res = new char[100];
    itoa(number, res);
    return res;
}

int numberToString(char* str)
{
    return atoi(str);
}

int booleanAnswerBinarySearch(Array<int> params, int left, int right, bool (*f)(Array<int> params, int v))
{
    if(f(params, left) && !f(params, left-1)) {
        return left;
    }

    if(f(params, right) && !f(params, right+1)) {
        return right;
    }

    int middle = (left+right)/2;
    int g = f(params, middle);
    if(g) {
        return booleanAnswerBinarySearch(params, left, middle, f);
    } else {
        return booleanAnswerBinarySearch(params, middle+1, right, f);
    }
}

Array< Array<int> > enumerarePermutations(int n)
{
    int fac = fact(n);
    Array<int> v;
    for(int i = 0; i<n; i++) {
        v.add(i+1);
    }
    Array< Array <int> > res;
    for(int i = 0; i<fac-1; i++) {
        Array<int> c(n);
        copy(v.array, v.array + v.size, c.array);
        res.add(c);
        next_permutation(v.array, v.array + v.size);
    }
    Array<int> c(n);
    copy(v.array, v.array + v.size, c.array);
    res.add(c);
    return res;
}

template <typename T>
Array< Array<T> > enumerarePermutations(Array<T> array)
{
    int n = array.size;
    int fac = fact(n);
    Array<T> v;
    for(int i = 0; i<n; i++) {
        v.add(array[i]);
    }
    Array< Array <T> > res;
    for(int i = 0; i<fac-1; i++) {
        Array<T> c(n);
        copy(v.array, v.array + v.size, c.array);
        res.add(c);
        next_permutation(v.array, v.array + v.size);
    }
    Array<T> c(n);
    copy(v.array, v.array + v.size, c.array);
    res.add(c);
    return res;
}

Array< Array<int> > enumerareTuples(int n, int k)
{
    int q = bpow(k, n);
    Array< Array<int> > res(q);
    for(int i = 0; i<q; i++) {
        Array<int> tuple(n);
        for(int j = 0; j<n; j++) {
            tuple[j] = (i/bpow(k, j))%k;
        }
        res[i] = tuple;
    }
    return res;
}

template <typename T>
Array< Array<int> > enumerareTuples(int n, Array<T> array)
{
    int k = array.size;
    int q = bpow(k, n);
    Array< Array<T> > res(q);
    for(int i = 0; i<q; i++) {
        Array<int> tuple(n);
        for(int j = 0; j<n; j++) {
            tuple[j] = array[(i/bpow(k, j))%k];
        }
        res[i] = tuple;
    }
    return res;
}

bool* sieve(int bound)
{
    bool* array = new bool[bound+1]();
    for(int i = 2; i*i<=bound; i++) {
        if(!array[i]) {
            for(int j = i+i; j<=bound; j+=i) {
                array[j] = 1;
            }
        }
    }
    return array;
}

int f(int k)
{
    return k&(k+1);
}

string alignLeft(string a, int length, char ch)
{
    if(a.length() < length) {
        a = string(length - a.length(), ch) + a;
    }
    return a;
}

string decToRadix(int n, int radix)
{
    string res("");
    if(n == 0) {
        res.push_back('0');
        return res;
    }
    while(n) {
        int digit = n%radix;
        res.push_back((char)(digit + '0'));
        n/=radix;
    }
    reverse(res.begin(), res.end());
    return res;
}

int radixToDec(string s, int radix)
{
    int res = 0;
    reverse(s.begin(), s.end());
    for(int i = 0; i<s.length(); i++) {
        res+=(s[i]-'0')*bpow(radix, i);
    }
    return res;
}

class F
{
public:
    int (*f)(int, int);
    int (*inverse)(int, int);
    int NEUTRAL;

    F(int(*pf)(int, int), int (*pinverse)(int, int), int n) {
        f = pf;
        inverse = pinverse;
        NEUTRAL = n;
    }

    F() {
    }

    int operator()(int a, int b) {
        return f(a, b);
    }

    int inversed(int a, int b) {
        return inverse(a, b);
    }
};

class BIT
{
public:
    F f;
    Array<int> tree;
    Array<int> array;

    BIT(F func, Array<int> source) {
        Array<int> arr(source.size);
        copy(source.begin(), source.end(), arr.begin());
        array = arr;
        f = func;

        Array<int> tr(source.size);
        tree = tr;

        for(int i = 0; i<source.size; i++) {
            add(i, array[i]);
        }
    }

    void add(int i, int delta) {
        for(int u = i; u<tree.size; u = u | (u+1)) {
            tree[u]=f(tree[u], delta);
        }
    }

    int value(int l, int r) {
        return f.inversed(p(r), p(l - 1));
    }

    int p(int v) {
        if(v < 0) {
            return 0;
        }
        if(v == 0) {
            return tree[0];
        } else {
            return f(tree[v], p((v&(v+1)) - 1));
        }
    }
};

class Graph{
public:
    int n = 0;
    int m = 0;
    vector<vector<int> > adj;
    vector<vector<int> > w;
    bool isDirected = false;
    bool isWeighted = false;

    Graph(){
    }

    void setDirected(){
        this->isDirected = true;
    }

    void setWeighted(){
        this->isWeighted = true;
    }

    Graph(int n){
        this->n = n;
        vector<vector<int> > _adj(2*n+1);
        vector<vector<int> > _w(2*n+1);
        adj = _adj;
        w = _w;
    }

    void readByMatrix(){
        bool last = this->isDirected;
        this->isDirected = true;
        for(int i = 0; i<n; i++){
            for(int j = 0; j<n; j++){
                int x;
                cin >> x;
                if(this->isWeighted){
                    if(x != -1){
                        this->addWeighted(i, j, x);
                    }
                }
                else{
                    if(x != 0){
                        this->add(i, j);
                    }
                }
            }
        }
        this->isDirected = last;
    }

    void printWeights(){
        for(int i = 0; i<n; i++){
            cout << i << " {";
            for(int j = 0; j<w[i].size(); j++){
                if(j!=adj[i].size()-1){
                    cout << w[i][j] << " ";
                }
                else{
                    cout << w[i][j];
                }
            }
            cout << "}";
            cout << endl;
        }
    }

    void add(int a, int b){
        this->m++;
        adj[a].push_back(b);
        if(!this->isDirected){
            this->m++;
            adj[b].push_back(a);
        }
    }

    void addWeighted(int a, int b, int weight){
        this->m++;
        adj[a].push_back(b);
        w[a].push_back(weight);
        if(!this->isDirected){
            this->m++;
            adj[b].push_back(a);
            w[b].push_back(weight);
        }
    }

    void dfs(int v, int* p, vector<int>& graypath, Array<int>& cycles, Array<int>& res, Array<int>& outs, int* color){
        color[v] = 1;
        res.add(v);
        graypath.push_back(v);
        for(int i = 0; i<adj[v].size(); i++){
            int u = adj[v][i];
            if(color[u] == 0){
                p[u] = v;
                dfs(u, p, graypath, cycles, res, outs, color);
            }

            if(color[u] == 1){
                if(p[v]!=u){
                    Array<int> cycle;
                    bool now = false;
                    for(int i = 0; i<graypath.size(); i++){
                        if(graypath[i] == u){
                            now = true;
                        }

                        if(now){
                            cycle.add(graypath[i]);
                        }

                        if(graypath[i] == v){
                            now = false;
                        }
                    }
                    cycles = cycle;
                }
            }
        }
        graypath.pop_back();
        color[v] = 2;
        outs.add(v);
    }

    Array<int> dfs(int number){
        int* color = new int[n]();
        int* p = new int[n]();
        Array<int> res;
        Array<int> outs;
        Array<int> cycles;
        vector<int> path;
        dfs(number, p, path, cycles, res, outs, color);
        return res;
    }

    Array<Array<int> > findConnectedComponents(){
        Array<Array<int> > res;
        int* array = new int[n]();
        for(int i = 0; i<n; i++){
            if(!array[i]){
                Array<int> component = dfs(i);
                for(int j = 0; j<component.size; j++){
                    array[component[j]] = i+1;
                }
                res.add(component);
            }
        }
        return res;
    }

    void shortestPath(Array<int>& p, int from, int to, Array<int>& res){
        if(from == to){
            res.add(from);
        }
        else{
            res.add(to);
            int newTo = p[to];
            shortestPath(p, from, newTo, res);
        }
    }

    Array<int> shortestPath(Array<int>& p, int from, int to){
        Array<int> res;
        shortestPath(p, from, to, res);
        reverse(res.begin(), res.end());
        return res;
    }

    Array<int> bfsPath(int s, int t){
        Array<int> p(n);
        Array<int> dists(n);
        bfs(p, dists, s);
        for(int i = 0; i<n; i++){
            dists[i] = -1;
        }
        return shortestPath(p, s, t);
    }

    Array<int> bfsDists(int root){
        Array<int> p(n);
        Array<int> dists(n);
        for(int i = 0; i<n; i++){
            dists[i] = -1;
        }
        bfs(p, dists, root);
        return dists;
    }

    Array<int> findCycles(){
        int* color = new int[n]();
        int* p = new int[n]();
        Array<int> res;
        Array<int> outs;
        Array<int> cycles;
        vector<int> graypath;
        dfs(0, p, graypath, cycles, res, outs, color);
        return cycles;
    }

    void bfs(Array<int>& p, Array<int>& dists, int root){
        queue<int> q;
        q.push(root);
        int* visited = new int[this->n]();
        visited[root] = true;
        dists[root] = 0;
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for(int i = 0; i<adj[v].size(); i++){
                int u = adj[v][i];
                if(!visited[u]){
                    visited[u] = true;
                    dists[u] = dists[v]+1;
                    p[u] = v;
                    q.push(u);
                }
            }
        }
    }

    Array<int> toposort(){
        n++;
        vector<int> newAdj;
        adj[n] = newAdj;
        for(int i = 0; i<n-1; i++){
           this->add(n-1, i);
        }
        Array<int> res;
        Array<int> outs;
        vector<int> path;
        Array<int> cycles;
        int* color = new int[n]();
        int* pr = new int[n]();
        dfs(n-1, pr, path, cycles, res, outs, color);
        n--;

        Array<int> p(outs.size - 1);
        for(int i = 0; i<outs.size - 1; i++){
            p[i] = outs[i];
        }
        reverse(p.begin(), p.end());

        Array<int> r(p.size);
        for(int i = 0; i<p.size; i++){
            r[p[i]] = i;
        }

        for(int i = 0; i<n; i++){
             for(int j = 0; j<adj[i].size(); j++){
                 int v = adj[i][j];
                 if(r[i]>=r[v]){
                     Array<int> sh(0);
                     return sh;
                 }
             }
        }

        return p;
    }

    int INF = 1000000000;
    int INFP = 1000000000/2;

    /*
    void Dijkstra(Array<int>& p, Array<int>& dists, int root){
        for(int i = 0; i<n; i++){
            dists.add(this->INF);
        }
        dists[root] = 0;

        for(int i = 0; i<n; i++){
            p.add(this->INF);
        }
        p[root] = root;

        int* used = new int[n]();
        int v = root;
        for(int i = 0; i<n; i++){
            used[v] = true;
            for(int j = 0; j<adj[v].size(); j++){
                int u = adj[v][j];
                if(used[u] == false){
                    int newD = dists[v]+w[v][j];
                    if(newD < dists[u]){
                        p[u] = v;
                        dists[u] = newD;
                    }
                }
            }

            int newV = -1;
            int minDist = this->INF+this->INF;
            for(int i = 0; i<n; i++){
                if(!used[i]){
                    if(dists[i] < minDist){
                        newV = i;
                        minDist = dists[i];
                    }
                }
            }

            v = newV;
        }
    }
    */

    void Dijkstra(Array<int>& p, Array<int>& d, int s){
        for(int i = 0; i<n; i++){
            d.add(this->INF);
        }
        d[s] = 0;

        for(int i = 0; i<n; i++){
            p.add(this->INF);
        }
        p[s] = s;

        set < pair<int,int> > q;
        q.insert (make_pair (d[s], s));
        while (!q.empty()) {
            int v = q.begin()->second;
            q.erase (q.begin());
            for (size_t j=0; j<adj[v].size(); ++j) {
                int to = adj[v][j];
                int len = w[v][j];
                if (d[v] + len < d[to]) {
                    q.erase (make_pair (d[to], to));
                    d[to] = d[v] + len;
                    p[to] = v;
                    q.insert (make_pair (d[to], to));
                }
            }
        }
    }
};

istream& operator>>(istream& in, Graph& g)
{
    int n;
    int m;
    cin >> n >> m;
    Graph graph(n);
    graph.isDirected = g.isDirected;
    graph.isWeighted = g.isWeighted;
    for(int i = 0; i<m; i++){
        int x;
        int y;
        cin >> x >> y;
        if(!graph.isWeighted){
            graph.add(x-1, y-1);
        }
        else{
            int w;
            cin >> w;
            graph.addWeighted(x-1, y-1, w);
        }
    }
    g = graph;
    return in;
}

ostream& operator<<(ostream& out, Graph& g)
{
    for(int i = 0; i<g.n; i++){
        out << i << " {";
        for(int j = 0; j<g.adj[i].size(); j++){
            if(j!=g.adj[i].size()-1){
                out << g.adj[i][j] << " ";
            }
            else{
                out << g.adj[i][j];
            }
        }
        out << "}";
        out << endl;
    }
    return out;
}

bool checkConstruction(Array<int> construction){
    for(int i = 0; i<construction.size; i++){
        int remain = construction.size - 1 - i;
        if(remain > construction[i]){
            return false;
        }
    }
    return true;
}

class Fenwick{
  int *m, *mt, N;
public:
  Fenwick(int n);
  Fenwick(int a[], int n);
  void add_range(int r, int d);
  void add_range(int l, int r, int d);
  int sum(int r);
  int sum(int l, int r);
};

Fenwick::Fenwick(int n){
  N = n;
  m = new int[N];
  mt = new int[N];
  memset(m, 0, sizeof(int)*N);
  memset(mt, 0, sizeof(int)*N);
}

Fenwick::Fenwick(int a[], int n){
  N = n;
  m = new int[N];
  mt = new int[N];
  memset(m, 0, sizeof(int)*N);
  memset(mt, 0, sizeof(int)*N);
  for(int i=0;i<N;++i){
    m[i] += a[i];
    if((i|(i+1))<N) m[i|(i+1)] += m[i];
  }
}

void Fenwick::add_range(int r, int d){
  if(r<0) return ;
  for(int i=r;i>=0;i=(i&(i+1))-1) mt[i] += d;
  for(int i=r|(r+1);i<N;i|=i+1) m[i] += d*(r-(i&(i+1))+1);
}
void Fenwick::add_range(int l, int r, int d){
  add_range(r, d);
  add_range(l-1, -d);
}

int Fenwick::sum(int r){
  if(r<0) return 0;
  int res = 0;
  for(int i=r;i>=0;i=(i&(i+1))-1) res += m[i] + mt[i]*(i-(i&(i+1))+1);
  for(int i=r|(r+1);i<N;i|=i+1) res += mt[i]*(r-(i&(i+1))+1);
  return res;
}
int Fenwick::sum(int l, int r){
  return sum(r) - sum(l-1);
}

#undef int
int main(void)
{
#define int long long int
RANDOM = 0;
srand (time(NULL));
//freopen("distance.in", "r", stdin);
//freopen("distance.out", "w", stdout);
//freopen("input.txt", "r", stdin);

    int bcount, gcount;
    cin >> bcount;
    Array<int> boys(bcount);
    cin >> boys;
    cin >> gcount;
    Array<int> girls(gcount);
    cin >> girls;

    int* used = new int[bcount]();

    for(int i = 0; i<gcount; i++){
        int pos = -1;
        int bestmatch = 1000000;
        for(int j = 0; j<bcount; j++){
            if(!used[j]){
                int match = abs(girls[i] - boys[j]);
                if(match <= 1){
                    if(match < bestmatch){
                        pos = j;
                        bestmatch = match;
                    }
                }
            }
        }
        used[pos] = 1;
    }

    int total = 0;
    for(int i = 0; i<bcount; i++){
        if(used[i]){
            total++;
        }
    }

    println(total);
}