#include #include #include using namespace std; int main() { int k, n; cin >> k >> n; vector a(n), b(n); for(int i = 0; i < n; i++) { cin >> a[i]; } for(int i = 0; i < n; i++) { cin >> b[i]; } sort(a.begin(), a.end()); sort(b.begin(), b.end()); long long result = 0; for(int i = 0; i < n; i++) { int x = k - a[i]; int idx = lower_bound(b.begin(), b.end(), x) - b.begin(); if(idx >= 0 and idx < n) { result += n - idx; } } cout << result << endl; return 0; }