#include <stdio.h>
#include <stdlib.h>

int main(void) {
    long long int start;
    long long int sub_value;

    scanf("%lld %lld", &start, &sub_value);

    long long int result = start % sub_value;

    long long int result2 = llabs(result - sub_value);
    printf("%lld\n", result2);

    if (result <= result2) {
        printf("%lld\n", result);
    } else {
        printf("%lld\n", result2);
    }

    return 0;
}
