import strutils, algorithm, tables var S = stdin.readLine.sorted(cmp) dic = initCountTable[string]() while true: dic.inc S.join if S.nextPermutation == false: break echo dic.len - 1