#include #include #include using namespace std; int main(){ string r, g, b; cin >> r >> g >> b; vector isexist_r(16, true), isexist_g(16, true), isexist_b(16, true); auto myctoi = [](char ch){ if('0' <= ch && ch <= '9') return ch-'0'; else return ch-'A'+10; }; if(r != "NONE"){ for(int i = 0; i < r.length(); i += 2){ isexist_r[myctoi(r[i])] = false; } } if(g != "NONE"){ for(int i = 0; i < g.length(); i += 2){ isexist_g[myctoi(g[i])] = false; } } if(b != "NONE"){ for(int i = 0; i < b.length(); i += 2){ isexist_b[myctoi(b[i])] = false; } } int ans = 0; for(int r1 = 0; r1 < 16; r1++){ if(!isexist_r[r1]) continue; for(int r0 = 0; r0 < 16; r0++){ if(!isexist_r[r0]) continue; for(int g1 = 0; g1 < 16; g1++){ if(!isexist_g[g1]) continue; for(int g0 = 0; g0 < 16; g0++){ if(!isexist_g[g0]) continue; for(int b1 = 0; b1 < 16; b1++){ if(!isexist_b[b1]) continue; for(int b0 = 0; b0 < 16; b0++){ if(isexist_b[b0]) ans++; } } } } } } cout << ans << endl; return 0; }