#include <bits/stdc++.h>

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000


bool flag = false;
vl res;
string s;
int n;
ll dfs1(ll m, ll u, ll val);
ll dfs2(ll m, ll u, ll val);
int maior = -1, menor = 11;
ll dfs1(ll m, ll u, ll val){
	if(m == n){
		return 1;
		flag = true;
	}

	for(int i = 1; i < 11; ++i){
		W(i, " ")
		W(s[i], " ")
		W(maior, endl)
		if(s[i] == '1' && i != u && 0 < val + i && val + i < maior){
			if(dfs2(m+1, i, val+i)){
				res[m] = i;
				return 1;
			}
		}
	}

	return 0;

}
ll dfs2(ll m, ll u, ll val){
	if(m == n){
		return 1;
		flag = true;
	}

	for(int i = 1; i < 11; ++i){
		if(s[i] == '1' && i != u && 0 > val - i && val - i > -maior){
			if(dfs1(m+1, i, val - i)){
				res[m] = i;
				return 1;
			}
		}
	}

	return 0;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

    ll a, b;
	cin >> a >> b;

	if(b%a == 0){
		cout << a + b << endl;
	} else{
		cout << b - a << endl;
	}
	
	return 0;
}
