#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("inline") #include using namespace std; inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } int main() { long long a = 1; int s = 0, m = 0, f = 0; while(true) { char c = my_getchar_unlocked(); if(c == EOF) { printf("%lld\n", a); exit(0); } if('0' <= c && c <= '9') { m += c; } else { if(m % 3 != 0) { s++; } m = 0; if(c == '\n') { if(f == 0) { f = 1; } else { a *= s; } s = 0; } } } }