#include<stdio.h>
#include<string.h>
#define true 1
#define false 0
#define MaxSize 40
int check(int* num1) {
    int i;
    for (i = 0; i < MaxSize; i++)if (num1[i] != 0)return false;
    return true;
}
int divide(int* num1, int m) {
    int i;
    for (i = 0; i < MaxSize - 1; i++) {
        num1[i + 1] += 10 * (num1[i] % m);
        num1[i] /= m;
    }
    int ans = num1[MaxSize - 1] % m;
    num1[MaxSize - 1] /= m;
    return ans;
}
int main() {
    char A[MaxSize], B[MaxSize];
    int i, j, m, n;
    scanf("%d", &m);
    if (m == 0)return 0;
    scanf("%s %s", A, B);
    int num1[MaxSize], num2[MaxSize];
    for (i = 0; i < MaxSize; i++)num1[i] = num2[i] = 0;
    for (i = strlen(A) - 1; i >= 0; i--)num1[MaxSize - strlen(A) + i] = A[i] - '0';
    for (i = strlen(B) - 1; i >= 0; i--)num2[MaxSize - strlen(B) + i] = B[i] - '0';
    for (i = 0; i < MaxSize; i++)num1[i] += num2[i];
    for (j = MaxSize - 1; j > 0; j--) {
        if (num1[j] >= m) {
            num1[j - 1] += num1[j] / 10;
            num1[j] %= 10;
        }
    }
    int ans[30];
    for (i = 0; i < 30; i++)ans[i] = 0;
    j = 0;
    if (check(num1) == true) {
        printf("0\n");
    } else {
        while (check(num1) != true) {
            int num = divide(num1, m);
            ans[j++] = num;
        }
        for (i = j - 1; i >= 0; i--)printf("%d", ans[i]);
    }
    printf("\n");
    return 0;
}