#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; string s; cin >> n >> s; vector cnt(10, 0); rep(i, s.size()) cnt[s[i] - '0']++; set st; rep(i, 10) rep(j, 10) rep(k, 10) { cnt[i]--, cnt[j]--, cnt[k]--; if (cnt[i] >= 0 && cnt[j] >= 0 && cnt[k] >= 0) { int x = i * 100 + j * 10 + k; st.insert(x % 40); } cnt[i]++, cnt[j]++, cnt[k]++; } cout << st.size() << '\n'; return 0; }