#include<bits/stdc++.h>
using namespace std;
int main(){
int A1,A2,A3,A4,A5,A6,A7,A8,A9,B1,B2,B3,B4,B5,B6,B7,B8;
cin>>A1>>A2>>A3>>A4>>A5>>A6>>A7>>A8>>A9>>B1>>B2>>B3>>B4>>B5>>B6>>B7>>B8;
cout<<A1+A2+A3+A4+A5+A6+A7+A8+A9-B1-B2-B3-B4-B5-B6-B7-B8+1;
return 0;
}