Under construction

Still being built. Things may change

Carry Count

Interview

Time limit1sMemory limit128 MB

Summary
For each pair of non-negative integers, count how many carries occur while adding them column by column from the right. Stop at the 0 0 line.
Level

Easy3 of 10

Topics
Implementation, Math, Simulation
Solved
No attempts yet

Problem

When adding multi-digit numbers, you add one column at a time starting from the rightmost digit and moving left. Whenever the sum of a single column is a two-digit number, you carry the 1 into the column immediately to its left. This is called a carry.

Given two integers, write a program that counts how many carries occur while adding them together.

Input

The input consists of several test cases. Each test case is a single line containing two integers, where each integer is a non-negative integer with at most 10 digits. The last line of the input is 0 0, and this line must not be processed.

Output

For each test case, print on its own line the number of carries that occur when the two numbers are added.

Examples6

  1. Example 1

    Input
    123 456
    555 555
    123 594
    0 0
    
    Expected output
    0
    3
    1
    
  2. Example 2

    Input
    9999999999 1
    0 0
    
    Expected output
    10
    
  3. Example 3

    Input
    111 111
    0 0
    
    Expected output
    0
    
  4. Example 4

    Input
    0 5
    0 0
    
    Expected output
    0
    
  5. Example 5

    Input
    1 999
    0 0
    
    Expected output
    3
    
  6. Example 6

    Input
    1 1
    99 1
    12345 54321
    0 0
    
    Expected output
    0
    2
    0