eolymp
bolt
Try our new interface for solving problems
Problems

Simple arithmetic

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 \textbf{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. \InputFile The first line introduces a whole number of \textbf{P}, determines the number system (\textbf{2} ≤ \textbf{Р} ≤ \textbf{62}). The second line is an integer \textbf{L_1} (\textbf{1} ≤ \textbf{L_1} ≤ \textbf{62000}) -- the length of the first term (in characters). Third row - the first term. The fourth line contains an integer \textbf{L_2} (\textbf{1} ≤ \textbf{L_2} ≤ \textbf{62000}) -- the length of the second term. The fifth line - second term. The figures for the base > \textbf{10} --- big letters (\textbf{A} - \textbf{Z}); grounds for > \textbf{36} --- small letters (\textbf{a} - \textbf{z}). \OutputFile Bring one integer - the number of transfer operations, which must comply with the addition of two numbers given in the \textbf{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.
Time limit 2 seconds
Memory limit 64 MiB
Input example #1
10
3
123
3
456
Output example #1
0