#include<cstdio>
#include<cstdlib>
#define MAX_N 5005
using namespace std;
int a [MAX_N], pSol [MAX_N], pOut [MAX_N], n;
long long numSol, numOut;
FILE *in, *sol, *out;

    int main(int argc, char * arg [])
    {
        in = fopen (arg [1], "r");
        out = fopen (arg [2], "r");
        sol = fopen (arg [3], "r");

        fscanf (sol, "%lld", &numSol);
        fscanf (out, "%lld", &numOut);

        if (numSol == numOut)
        {
            fscanf (in, "%d", &n);
            for (int i = 0; i < n; i++)
            {
                fscanf (in, "%d", &a [i]);
            }

            long long x = 0;
            for (int i = 0; i < n; i++)
            {
                fscanf (out, "%d", &pOut [i]);
                x += abs(pOut [i]);
            }

            if (x == numOut)
            {
                for (int i = 0; i < n; i++)
                {
                    a [i] += pOut [i];
                }

                bool ok = true;
                for (int i = 0; i < n - 1; i++)
                {
                    if (a [i] >= a [i + 1])
                    {
                        ok = false;
                        break;
                    }
                }

                if (ok)
                {
                    printf ("5\n");
                }
                else
                {
                    printf ("0\n");
                }
            }
            else
            {
                printf ("0\n");
            }
        }
        else
        {
            printf ("0\n");
        }

        fclose(in);
        fclose(out);
        fclose(sol);

        return 0;
    }

