you keyboard layout show XY plane English uppercase letter locate coordinatefor example letter a locate coordinate 0 0 letter b locate coordinate 0 1 letter p locate coordinate 2 3 letter Z located coordinate 4 1given string word return minimum total distance type string fingersThe distance coordinate x1 y1 x2 y2 x1 x2 y1 y2Note initial position finger consider free count total distance finger start letter letter Example 1input word CAKEOutput 3explanation use finger optimal way type cake Finger 1 letter C cost 0 finger 1 letter a cost distance letter c letter a 2 finger 2 letter K cost 0 Finger 2 letter e cost Distance letter K letter e 1 total distance 3example 2input word HAPPYOutput 6explanation use finger optimal way type HAPPY isfinger 1 letter H cost 0finger 1 letter a cost distance letter h letter a 2finger 2 letter p cost 0finger 2 letter p cost Distance letter p letter p 0finger 1 letter Y cost distance letter a letter Y 4total distance 6 constraints2 wordlength 300word consist uppercase english letter