#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); set S; for(int i=0; i<6; i++){ string s; cin >> s; int x = stoi(s); S.insert(x); } vector already(1000000); already.at(0) = true; queue Q; Q.push(0); int answer = 0; while(Q.size()){ int pos = Q.front(); Q.pop(); answer++; for(auto s : S){ int x = pos,y = s; string st = ""; for(int k=0; k<6; k++){ int a = x%10+y%10; a %= 10; st += '0'+a; x /= 10,y /= 10; } reverse(st.begin(),st.end()); int next = stoi(st); if(!already.at(next)) already.at(next) = true,Q.push(next); } } cout << answer << endl; }