# Python3 program for the above approach
# Function that calculates the moves
# required to print current String
def numberMoves(s):
# row1 has qwertyuiop, row2 has
# asdfghjkl, and row3 has zxcvbnm
# Store the row number of
# each character
row = [2, 3, 3, 2, 1, 2,
2, 2, 1, 2, 2, 2, 3,
3, 1, 1, 1, 1, 2, 1,
1, 3, 1, 3, 1, 3];
# String length
n = len(s);
# Initialise move to 1
move = 1;
# Traverse the String
for i in range(1, n):
# If current row number is
# not equal to previous row
# then increment the moves
if(row[ord(s[i]) -
ord('a')] != row[ord(s[i - 1]) -
ord('a')]):
move += 1;
# Return the moves
return move;
# Driver Code
if __name__ == '__main__':
# Given String str
str = "geeksforgeeks";
# Function Call
print(numberMoves(str));
# This code is contributed by Rajput-Ji Add