JEDNAKOS - JEDNAKOST

While browsing a math book, Mirko found a strange equation of the form A=S. What makes the equation strange is that A and S are not the same, which makes the equation incorrect. Mirko realized that the left side of the equation should have addition operations between some pairs of digits in A. Write a program that inserts the smallest number of addition operations on the left side to make the equation correct. The numbers in the corrected equation may contain arbitrary amounts of leading zeros.

Input

The first line contains the equation in the form A=S.

A and S will both be positive integers without leading zeros. They will be different.

A will contain at most 1000 digit

S will be less than or equal to 5000

Note: The input data will guarantee that a solution, although not necessarily unique, will always exist.

Output

Output the number of addition operations needed.

Example

Input:
143175=120

Output:
2
Input:
5025=30

Output:
1
Input:
999899=125

Output:
4


Được gửi lên bởi:sieunhan
Ngày:2009-01-21
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: GOSU PERL6 PYPY RUST SED
Nguồn bài:Croatia regional competition 2008

hide comments
2017-09-30 11:44:25


Last edit: 2017-10-03 02:56:26
2017-09-29 16:45:13
Quang Điện óc vãi, vượt time kìa?
2017-08-27 09:21:23
Bài này phải cài khéo mới ac, không thì sẽ quá time
2017-07-24 01:18:46
nhìn dễ mà vẫn k 1 đấm được :/
@letrongdat
2014-08-12 13:25:01 Nắng
debug phê vồn
2014-03-06 12:31:51 Anh Duc Le
Hình như có test vượt giới hạn đề, tăng giới hạn 2 lần mới AC :v
2012-07-18 22:58:23 Кто это
Bài này C/C++ phải cẩn thận, kết thúc line là \r\n => scanf đọc thêm cả \r!!
2010-07-08 11:15:56 thphong
Mọi người chú ý test 10000...000=1, test này có thể làm quá thời gian đấy
2010-07-08 10:50:17 thphong
14+31+75=120
2010-02-03 12:34:05 phicuong
cai dau phai 3 dau +chu nhi?
1+43+1+75
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.