#include <iostream>
using namespace std;

int main() {
	int d,m,y, exd, exm, exy;
	cin>>d>>m>>y;
	cin>>exd>>exm>>exy;
	
	if( exy < y){
		cout<<10000;
	}
	else if ( exy > y){
		cout<<0;
	}
	else if ( exm < m){
		cout<< (m - exm) * 500;
	}
	else if( exm > m){
		cout<<0;
	}
	else if( exd < d){
		cout<< ( d - exd) * 15;
	}
	else{
		cout<< 0;
	}
	
	// your code goes here
	return 0;
}