Exact Change

시간 제한1초메모리 제한2048 MB

요약
이진수로 주어진 a와 b에 대해 a부터 b까지 모든 금액을 정확히 지불할 수 있는 최소 2의 거듭제곱 동전 개수를 구한다.
난이도

보통10점 중 7점

유형
그리디, 수학, 비트 연산, 문자열 매칭
정답자
아직 제출이 없습니다

문제

While in Binaria, you find a store where you want to buy some presents for your friends. In Binaria, the currency is bits, and the coin denominations are the set of all integer powers of 22. You know that you want to spend at least aa bits here, but no more than bb bits.

When you make a purchase, you must pay with exact change. You have an unlimited number of bits that you can access from your bank account, but you can choose to withdraw them in whatever denominations you find most convenient. Carrying many coins is inconvenient though, so you wish to minimize the number of coins you carry with you.

Compute the minimum number of coins you need to bring with you such that you can pay any integer amount of bits between aa and bb, inclusive.

입력

The first line of input contains a single integer aa, 1≤a<210000001 \le a < 2^{1000000}. aa will be written in base 2 with no leading zeros.

The second line of input contains a single integer bb, a≤b<21000000a \le b < 2^{1000000}. bb will be written in base 2 with no leading zeros.

출력

Output a single integer kk, the minimum number of coins you need to bring.

예제2

  1. 예제 1

    입력
    10101
    101010
    
    예상 출력
    6
    
  2. 예제 2

    입력
    100
    101
    
    예상 출력
    2