#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, a, n) for(int i = a; i < n; i++) #define rrep(i, a, n) for(int i = a; i >= n; i--) #define inr(l, x, r) (l <= x && x < r) #define ll long long #define ld long double // using mint = modint1000000007; // using mint = modint998244353; constexpr int IINF = 1001001001; constexpr ll INF = 1e18; template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;} template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;} int main(){ int n, f; cin >> n >> f; vector<int> a(n), b(n), c(n); rep(i, 0, n) cin >> a[i]; rep(i, 0, n) cin >> b[i]; rep(i, 0, n) cin >> c[i]; vector<bool> d(1, true); set<int> s; rep(i, 0, n){ vector<bool> e(f+1); e[a[i]] = true; e[b[i]] = true; e[c[i]] = true; if(a[i]*b[i]*c[i] != 0) d[0] = false, s.insert(0); vector<bool> g = convolution(e, d); // cout << g.size() << endl; rep(j, i*f+1, (i+1)*f+1){ s.insert(j); } auto itr = s.begin(); while(itr != s.end()){ // cout << *itr << endl; if(g[*itr]){ s.erase(itr++); }else{ itr++; } } cout << ((i+1)*f+1)-s.size() << endl; swap(d, g); } return 0; }