
R-mahjong ⅠⅠⅠ: count shanten

This is the third mission in the series about the game riichi mahjong. This mission is more difficult than the previous ones, so be prepared.
This time, your task is to determine which is the smallest number of tiles in the hand you need to replace in order to make it a winning one. In other words, it is necessary to determine its so-called shanten number. Remember that there is not only the standard "four sets and a pair" hand pattern, but also chitoitsu and kokushi-muso.
For simplicity, the possibility of open sets is omitted. However, you should thoroughly check the input data and, if it is invalid, return None.
Here are the explanatory examples:
In the next hand, you need to replace only one tile ("tempai"):
['p4', 'p5', 'p6', 'm1', 'm1', 'm1', 's2', 's3', 's4', 's5', 'we', 'we', 'dw', 'dw']
And this one has three tiles to replace:
['p4', 'p5', 'p6', 'm1', 'm1', 'm1', 's2', 's3', 's4', 's6', 'we', 'ws', 'dw', 'dw']
Input data: One argument — a list of strings encoding tiles.
Output data: An int type variable: the number of shanten in the hand.
Example:
riichi_mahjong_shanten(['p4', 'p5', 'p6', 'm1', 'm1', 'm1', 's2', 's3', 's4', 's5', 'we', 'we', 'dw', 'dw']) == 1