Simple arithmetic
Children are taught to add multi-digit numbers from right to left, one digit at a time. Many children consider the operation of 'transfer' when one moves to the next level, rather complex. Your job is to count the number of transfer operations for each task in addition (to assess its complexity). We generalize the problem and solve it for any R-s numbers.
Children are taught to add multi-digit numbers from right to left, one digit at a time. Many children consider the operation of 'transfer' when one moves to the next level, rather complex. Your job is to count the number of transfer operations for each task in addition (to assess its complexity). We generalize the problem and solve it for any R-s numbers.
Input
The first line introduces a whole number of P, determines the number system (2 ≤ Р ≤ 62). The second line is an integer L_1 (1 ≤ L_1 ≤ 62000) – the length of the first term (in characters). Third row - the first term. The fourth line contains an integer L_2 (1 ≤ L_2 ≤ 62000) – the length of the second term. The fifth line - second term.
The figures for the base > 10 — big letters (A - Z); grounds for > 36 — small letters (a - z).
Output
Bring one integer - the number of transfer operations, which must comply with the addition of two numbers given in the R-th system.
Bring one integer - the number of transfer operations, which must comply with the addition of two numbers given in the R-th system.