#!ruby -n d=0 gsub(/...|$/){$y=" £Ç¬Ïy¦wÍ".index(x=$&.hash%?ï)||!d+=($y||x%2)*10**x%=5} p d