#include #ifndef KAMMYU_CONSTANTS #define KAMMYU_CONSTANTS #include namespace kammyu { namespace infinities { constexpr int inf = std::numeric_limits::max(); constexpr int _inf = std::numeric_limits::min(); constexpr long long INF = std::numeric_limits::max(); constexpr long long _INF = std::numeric_limits::min(); }; // namespace infinities namespace modulos { constexpr int Smod = 998244353; constexpr int Bmod = 1000000007; }; // namespace modulos }; // namespace kammyu #endif // KAMMYU_CONSTANTS #ifndef KAMMYU_INPUT #define KAMMYU_INPUT #include #include #include #include namespace kammyu { namespace input { template std::istream& operator>>(std::istream& is, std::pair& p) { return is >> p.first >> p.second; } template std::istream& operator>>(std::istream& is, std::vector& v) { for (T& x : v) is >> x; return is; } template void inp_arr(std::vector& v) { for (T& i : v) std::cin >> i; } template void inp_arr(std::vector& v1, std::vector& v2) { for (int i = 0; i < (int)v1.size(); i++) std::cin >> v1[i] >> v2[i]; } template void inp_arr(std::vector& v1, std::vector& v2, std::vector& v3) { for (int i = 0; i < (int)v1.size(); i++) std::cin >> v1[i] >> v2[i] >> v3[i]; } template void inp_arr(std::vector& v1, std::vector& v2, std::vector& v3, std::vector& v4) { for (int i = 0; i < (int)v1.size(); i++) std::cin >> v1[i] >> v2[i] >> v3[i] >> v4[i]; } template void inp_arr(std::vector>& v) { for (std::vector& i : v) for (T& j : i) std::cin >> j; } }; // namespace input }; // namespace kammyu #endif // KAMMYU_INPUT #ifndef KAMMYU_OUTPUT #define KAMMYU_OUTPUT #include #include #include namespace kammyu { namespace output { template std::ostream& operator<<(std::ostream& os, const std::vector>& v) { for (const std::vector& x : v) os << x << "\n"; return os; } template std::ostream& operator<<(std::ostream& os, const std::vector& v) { for (const T& x : v) os << x << " "; return os; } void yes(bool o = false) { if (o) std::cout << "Yes"; else std::cout << "Yes" << std::endl; } void no(bool o = false) { if (o) std::cout << "No"; else std::cout << "No" << std::endl; } void yn(bool b, bool o = false) { if (b) yes(o); else no(o); } }; // namespace output }; // namespace kammyu #endif // KAMMYU_OUTPUT #ifndef KAMMYU_POINT #define KAMMYU_POINT #include #include #include namespace kammyu { namespace point { struct P { private: using ll = long long; public: P() { P(0, 0); } P(ll _i, ll _j) : i(_i), j(_j) {} ll i, j; bool operator==(const P& p) const { return i == p.i && j == p.j; } bool operator!=(const P& p) const { return !(*this == p); } bool operator<(const P& other) const { return std::tie(i, j) < std::tie(other.i, other.j); } bool operator>(const P& other) const { return std::tie(i, j) > std::tie(other.i, other.j); } P operator+(const P& other) const { return P(i + other.i, j + other.j); } P operator-(const P& other) const { return P(i - other.i, j - other.j); } P operator*(const int& other) const { return P(i * other, j * other); } P operator*(const ll& other) const { return P(i * other, j * other); } P operator*(const P& other) const { return P(i * other.i, j * other.j); } P operator*(const double& other) const { return P(i * other, j * other); } P operator/(const ll& scaler) const { return P(i / scaler, j / scaler); } P operator/(const double& scaler) const { return P(i / scaler, j / scaler); } P operator+=(const P& p) { return *this = *this + p; } P operator-=(const P& p) { return *this = *this - p; } P operator*=(const ll& p) { return *this = *this * p; } friend std::ostream& operator<<(std::ostream& os, const P& p) { return os << p.i << " " << p.j; } friend std::istream& operator>>(std::istream& is, P& p) { return is >> p.i >> p.j; } bool out_of_bounds(ll size) const { return i < 0 || j < 0 || i >= size || j >= size; } bool out_of_bounds(ll H, ll W) const { return i < 0 || j < 0 || i >= H || j >= W; } P& operator--() { --i, --j; return *this; } P operator--(int) { P p = *this; --(*this); return p; } void swap() { std::swap(i, j); } ll distEucSq() const { return i * i + j * j; } ll distManh() const { return i + j; } }; using piP = std::pair; using pPP = std::pair; using vP = std::vector

; using vpiP = std::vector; using vpPP = std::vector; using vvP = std::vector>; using vvpiP = std::vector>; const vP around4({P(0, 1), P(1, 0), P(0, -1), P(-1, 0)}); const vP around8({P(0, 1), P(1, 1), P(1, 0), P(1, -1), P(0, -1), P(-1, -1), P(-1, 0), P(-1, 1)}); }; // namespace point }; // namespace kammyu #endif // KAMMYU_POINT #ifndef KAMMYU_UTILS #define KAMMYU_UTILS #include #include #include #include #include #include #include #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i, n) for (int i = 0; i < (n); ++i) #define repp(i, s, e) for (int i = (s); i < (e); ++i) #define reep(i, n) for (int i = 0; i <= (n); ++i) #define reepp(i, s, e) for (int i = (s); i <= (e); ++i) #define rrep(i, n) for (int i = (n - 1); i >= 0; --i) #define rrepp(i, s, e) for (int i = (e - 1); i >= s; --i) #define sign(f) (f == 0 ? 0 : ((f) > 0) * 2 - 1) #define pqueue priority_queue namespace kammyu { namespace utils { template bool chmax(T1& m, const T2& val) { if (m < val) { m = val; return true; } return false; } template bool chmin(T1& m, const T2& val) { if (m > val) { m = val; return true; } return false; } using ll = long long; using pii = std::pair; using piii = std::pair; using si = std::set; using vi = std::vector; using vpii = std::vector; using vpiii = std::vector; using vvi = std::vector>; using vvpii = std::vector>; using vvvi = std::vector; using vvvvi = std::vector; using vb = std::vector; using vvb = std::vector; using pli = std::pair; using plii = std::pair; using vpli = std::vector; using vvpli = std::vector>; using pll = std::pair; using plll = std::pair; using vl = std::vector; using vpll = std::vector; using vvl = std::vector>; using vvpll = std::vector>; using vvvl = std::vector; using vvvvl = std::vector; using vsi = std::vector>; using vs = std::vector; template using vv = std::vector>; template using min_pqueue = std::priority_queue, std::greater>; template using max_pqueue = std::priority_queue; template std::pair operator+(const std::pair& a, const std::pair& b) { return std::make_pair(a.first + b.first, a.second + b.second); } template std::pair operator-(const std::pair& a, const std::pair& b) { return std::make_pair(a.first - b.first, a.second - b.second); } template void sort(std::vector& v) { std::sort(all(v)); } vi str2vi(const std::string& s, char first_char = 'a') { vi res(s.size()); rep(i, s.size()) res[i] = s[i] - first_char; return res; } template T sum(const std::vector& vec) { T res = T(); for (const T& val : vec) res = res + val; return res; } template T min(const std::vector& vec, T init) { T res = init; for (const T& val : vec) if (val < res) res = val; return res; } template T max(const std::vector& vec, T init) { T res = init; for (const T& val : vec) if (val > res) res = val; return res; } }; // namespace utils }; // namespace kammyu #endif // KAMMYU_UTILS using namespace kammyu::utils; using namespace kammyu::input; using namespace kammyu::output; using namespace kammyu::point; void MAIN(); int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); MAIN(); return 0; } using namespace std; void solve(); void precalc(); void MAIN() { precalc(); int T = 1; // cin >> T; while (T--) solve(); return; } // using namespace kammyu::infinities; // using namespace kammyu::modulos; void precalc() { return; } void solve() { int N, M; cin >> N >> M; vb can(2e5 + 1, false); while (N--) { int u; cin >> u; can[u] = true; } while (M--) { int t; cin >> t; rrepp(i, t, 2e5 + 1) if (can[i - t]) can[i] = true; } int cnt = 0; rep(i, 2e5 + 1) cnt += can[i]; cout << cnt << endl; return; }