#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int WA[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int N = getint(), M = getint();

	rep(i, M) {
		int p = 0;
		char c;
		if (ci - cn + 16 > cm) {
			while ((ct = getcha()) >= '0') p = p * 10 + ct - '0';
			c = getcha();
			getcha();
			getcha();
		}
		else {
			while ((ct = *ci++) >= '0') p = p * 10 + ct - '0';
			c = *ci;
			ci += 3;
		}

		if (WA[p] >= 0) {
			if (c == 'A') WA[p] = -WA[p] - 1;
			else WA[p]++;
		}
	}

	int kotae1 = 0;
	int kotae2 = 0;
	rep1(i, N) {
		if (WA[i] < 0) {
			kotae1++;
			kotae2 -= WA[i];
		}
	}
	printf("%d %d\n", kotae1, kotae2 - kotae1);

	Would you please return 0;
}


#include <cstdio>
#include <cctype>
#include <bitset>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
inline int gc()noexcept { return getchar_unlocked(); }
inline int input()noexcept {
	int v = 0; char c = gc();
	for (; isdigit(c); c = gc()) {
		v *= 10;
		v += c - '0';
    }
	return v;
}
bitset<100002> flag;
int main() {
  int n = input(), m = input();
  vector<int> cnt(n);
  int a1 = 0, a2 = 0;
  rep(i, m) {
    int p = input(); --p;
    char c = gc(); gc(); gc();
    if (!flag.test(p)) {
      switch(c) {
        case 'A':
          flag.set(p);
          ++a1;
          break;
        case 'W':
          ++cnt[p];
          break;
      }
    }
  }
  rep(i, n)if (flag.test(i))a2 += cnt[i];
  printf("%d %d", a1, a2);
}


#include <bits/stdc++.h>

class kin{
public:
	inline void open(FILE *,int);
	inline void close(void);
	inline void scan(void);
	inline kin &operator>(char &);
	inline kin &operator>(int &);
	inline kin &operator>(long long &);
	inline kin &operator>(double &);
	inline kin &operator>(long double &);
	inline kin &operator>(char *);
	template<class T>
	inline void get(T *,int);
private:
	FILE *fp;
	char *buf;
	int siz;
	int idx;
}in;

class kout{
public:
	inline void open(FILE *,int);
	inline void close(void);
	inline void print(void);
	inline kout &operator<(char);
	inline kout &operator<(int);
	inline kout &operator<(long long);
	inline kout &operator<(double);
	inline kout &operator<(long double);
	inline kout &operator<(const char *);
	template<class T>
	inline void put(T *,int,char,char);
private:
	FILE *fp;
	char *buf;
	int siz;
	int idx;
}out;

int main(int argc,char **argv){
	in.open(stdin,512);
	out.open(stdout,512);
	in.scan();
	int n,m;
	in>n>m;
	int d[100001];
	for(int i=1;i<=n;++i) d[i]=0;
	int ac=0,pena=0;
	for(int i=0;i<m;++i){
		int p;
		in>p;
		char s[2];
		in>s;
		if(d[p]<0) continue;
		if(s[0]=='A'){
			pena+=d[p];
			++ac;
			d[p]=-1;
		}
		else ++d[p];
	}
	out<ac<' '<pena<'\n';
	out.print();
	in.close();
	out.close();
	return 0;
}

inline void kin::open(FILE *fparg,int sizarg){
	fp=fparg;
	buf=new char[sizarg];
	siz=sizarg;
	idx=0;
	return;
}
inline void kin::close(void){
	fp=nullptr;
	delete[] buf;
	buf=nullptr;
	siz=0;
	idx=0;
	return;
}
inline void kin::scan(void){
	int readsiz=(int)std::fread((void *)buf,(std::size_t)1,(std::size_t)siz,fp);
	if(readsiz!=siz) buf[readsiz]='\x00';
	idx=0;
	return;
}
inline kin &kin::operator>(char &var){
	if(!buf[idx]){
		var='\x00';
		return *this;
	}
	var=buf[idx];
	if(++idx==siz) scan();
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(int &var){
	if(!buf[idx]){
		var=0;
		return *this;
	}
	int sign=-1;
	if(buf[idx]=='-'){
		sign=1;
		if(++idx==siz) scan();
	}
	var=0;
	while(buf[idx]>='0'){
		var=var*10-(int)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(long long &var){
	if(!buf[idx]){
		var=0LL;
		return *this;
	}
	long long sign=-1LL;
	if(buf[idx]=='-'){
		sign=1LL;
		if(++idx==siz) scan();
	};
	var=0LL;
	while(buf[idx]>='0'){
		var=var*10LL-(long long)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(double &var){
	if(!buf[idx]){
		var=0.0;
		return *this;
	}
	double sign=-1.0;
	if(buf[idx]=='-'){
		sign=1.0;
		if(++idx==siz) scan();
	}
	var=0.0;
	while(buf[idx]>='0'){
		var=var*10.0-(double)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	if(buf[idx]=='.'){
		if(++idx==siz) scan();
		double dig=1.0;
		while(buf[idx]>='0'){
			var-=(double)(buf[idx]-'0')*(dig/=10.0);
			if(++idx==siz) scan();
		}
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(long double &var){
	if(!buf[idx]){
		var=0.0L;
		return *this;
	}
	long double sign=-1.0L;
	if(buf[idx]=='-'){
		sign=1.0L;
		if(++idx==siz) scan();
	}
	var=0.0L;
	while(buf[idx]>='0'){
		var=var*10.0L-(long double)(buf[idx]-'0');
		if(++idx==siz) scan();
	}
	if(buf[idx]=='.'){
		if(++idx==siz) scan();
		long double dig=1.0L;
		while(buf[idx]>='0'){
			var-=(long double)(buf[idx]-'0')*(dig/=10.0L);
			if(++idx==siz) scan();
		}
	}
	var*=sign;
	if(++idx==siz) scan();
	return *this;
}
inline kin &kin::operator>(char *str){
	if(!buf[idx]){
		str[0]='\x00';
		return *this;
	}
	int ptr=0;
	while(buf[idx]>='!'){
		str[ptr++]=buf[idx];
		if(++idx==siz) scan();
	}
	str[ptr]='\x00';
	if(++idx==siz) scan();
	return *this;
}
template<class T>
inline void kin::get(T *arr,int num){
	for(int i=0;i<num;++i) (*this)>arr[i];
	return;
}

inline void kout::open(FILE *fparg,int sizarg){
	fp=fparg;
	buf=new char[sizarg];
	siz=sizarg;
	idx=0;
	return;
}
inline void kout::close(void){
	fp=nullptr;
	delete[] buf;
	buf=nullptr;
	siz=0;
	idx=0;
	return;
}
inline void kout::print(void){
	std::fwrite((void *)buf,(std::size_t)1,(std::size_t)idx,fp);
	idx=0;
	return;
}
inline kout &kout::operator<(char val){
	buf[idx]=val;
	if(++idx==siz) print();
	return *this;
}
inline kout &kout::operator<(int val){
	if(val<0){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1;
	char dig[10];
	int ptr=0;
	do{
		int tmp=val/10;
		dig[ptr++]=(char)-(val-tmp*10)+'0';
		val=tmp;
	}while(val);
	while(ptr--){
		buf[idx]=dig[ptr];
		if(++idx==siz) print();
	}
	return *this;
}
inline kout &kout::operator<(long long val){
	if(val<0LL){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1LL;
	char dig[19];
	int ptr=0;
	do{
		long long tmp=val/10LL;
		dig[ptr++]=(char)-(val-tmp*10LL)+'0';
		val=tmp;
	}while(val);
	while(ptr--){
		buf[idx]=dig[ptr];
		if(++idx==siz) print();
	}
	return *this;
}
inline kout &kout::operator<(double val){
	if(val<0.0){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1.0;
	double dig=1.0;
	while(val/dig<=-10.0) dig*=10.0;
	int tmp;
	while(dig>=1.0){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(double)tmp*dig;
		dig/=10.0;
	}
	buf[idx]='.';
	if(++idx==siz) print();
	for(int i=0;i<12;++i){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(double)tmp*dig;
		dig/=10.0;
	}
	return *this;
}
inline kout &kout::operator<(long double val){
	if(val<0.0L){
		buf[idx]='-';
		if(++idx==siz) print();
	}
	else val*=-1.0L;
	long double dig=1.0L;
	while(val/dig<=-10.0L) dig*=10.0L;
	int tmp;
	while(dig>=1.0L){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(long double)tmp*dig;
		dig/=10.0L;
	}
	buf[idx]='.';
	if(++idx==siz) print();
	for(int i=0;i<16;++i){
		buf[idx]=(char)-(tmp=(int)(val/dig))+'0';
		if(++idx==siz) print();
		val-=(long double)tmp*dig;
		dig/=10.0L;
	}
	return *this;
}
inline kout &kout::operator<(const char *str){
	for(int i=0;str[i];++i){
		buf[idx]=str[i];
		if(++idx==siz) print();
	}
	return *this;
}
template<class T>
inline void kout::put(T *arr,int num,char dlm,char end){
	--num;
	for(int i=0;i<num;++i) (*this)<arr[i]<dlm;
	(*this)<arr[num]<end;
	return;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int p;
    string s;
    int corr = 0, pen = 0;
    bool was[n]; for (int i = 0; i < n; i++) was[i] = false;
    for (int i = 0; i < m; i++){
        cin >> p >> s;
        if (s == "AC"){
            if (!was[p-1]){
                was[p-1] = true;
                corr++;
            }
        }
        else{
            if (!was[p-1]) pen++;
        }
    }
    cout << corr << ' ' << pen << "\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#pragma GCC optimize("O2")
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
const int mod = 1e9 + 7;
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
const int MAXN = 2e5+ 10;
const ll inf = 1e18;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
void read(vi & a) {
    for (int i = 0; i < sz(a); ++i) {
        cin >> a[i];
    }
}
int32_t main() {
    fio
    int n,m;
    cin >> n >> m;
    vi p(m);
    vector<vector<string>> subs(n,vector<string>(0));
    vector<string> s(m);
    for (int i = 0; i < m; ++i) {
        cin >> p[i] >> s[i];
        subs[p[i] - 1].pb(s[i]);
    }
    int cnt = 0;
    int ans = 0;
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < sz(subs[j]); ++i) {
            if(subs[j][i] == "WA") {
                cnt++;
            }
            else if(subs[j][i] == "AC") {
                ans++;
                break;
            }
        }
    }
    cout << ans <<" " << cnt << endl;

}


# coding: utf-8

def main():
    N, M = map(int, input().split())
    ans = [0, 0]
    A = [[0, 0] for _ in range(N)]

    for i in range(M):
        p, s = input().split()
        p = int(p)
        if s == 'AC':
            A[p - 1][1] = 1
        elif A[p - 1][1] == 0:
            A[p - 1][0] += 1

    for i, j in A:
        if i == 1:
            ans[0] += 1
            ans[1] += j

    print(ans[0], ans[1])

if __name__ == "__main__":
    main()


// ABC 151-C
// 2020.1.12 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0; int c;
	do c = gc();
	while (isspace(c));
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int WA[100005];
int AC, NG;

int main()
{
	int p, N, M, S;

	N = in(), M = in();
	while (M--) {
		p = in(), S = gc(), gc(), gc();
		if (S == 'A') {
			if (WA[p] >= 0) {
				++AC;
				NG += WA[p];
				WA[p] = -1;
			}
		} else {
			if (WA[p] >= 0) ++WA[p];
		}
	}
	printf("%d %d\n", AC, NG);
	return 0;
}


// ABC 151-C
// 2020.1.12 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0; int c;
//	do c = gc();
//	while (isspace(c));
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int WA[100005];
int AC, NG;

int main()
{
	int N, M;

	N = in(), M = in();
	while (M--) {
		int p = in();
		int S = gc(); gc(), gc();
		if (WA[p] < 0) continue;
		if (S == 'A') {
			++AC, NG += WA[p];
			WA[p] = -1;
		} else ++WA[p];
	}
	printf("%d %d\n", AC, NG);
	return 0;
}


#include<stdio.h>
int main(void){
int n,m,WA=0,AC=0;
  scanf("%d%d",&n,&m);
  int a,wc[100000]={};//なんこ目の問題か
	char s[3];
  for(int i=0;i<m;i++){
	scanf("%d %s",&a,s);
   if(wc[a]==-1)continue;
    if(s[0]=='W')wc[a]++;
    else {
      WA+=wc[a];
      wc[a]=-1;
      AC++;
    }

  }
  printf("%d %d",AC,WA);
  return 0;
}


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

int main(){
    int N, M, *p, i, acsum, wasum, *ac, *wa;
    char str[8];
    p = (int *)malloc(M * sizeof(int));
    ac = (int *)malloc(N * sizeof(int));
    wa = (int *)malloc(N * sizeof(int));
    scanf("%d %d", &N, &M);
    for(i = 0;i < M;i++){
        scanf("%d %s", &p[i], str);
        if(strcmp(str, "AC") == 0 && ac[p[i] - 1] == 0){
            ac[p[i] - 1] = 1;
        }else if(strcmp(str, "WA") == 0 && ac[p[i] - 1] != 1){
            wa[p[i] - 1] += 1;
        }
         printf("ac[%d] = %d, wa[%d] = %d\n", i, ac[p[i]-1], i, wa[p[i]-1]);
    }
    for(i = 0;i < N;i++){
        if(ac[i] == 1){
            wasum += wa[i];
        }
        acsum += ac[i];
    }
    printf("%d %d\n", acsum, wasum);
    free(p);
    free(ac);
    free(wa);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int N, M, ac, wa, *count, *er, d;
  char str[8];
  scanf("%d %d", &N, &M);
  ac = 0;
  wa = 0;
  er = (int *)malloc(N * sizeof(int));
  count = (int *)malloc(N * sizeof(int));
  for(int i = 0; i < M;i++){
    scanf("%d %s", &d, str);
    if(strcmp(str, "WA") == 0 && count[d-1] != 1){
      er[d-1] += 1;
    }else if(strcmp(str, "AC") == 0 && count[d-1] != 1){
      ac += 1;
        count[d-1] = 1;
    }
  }
    for(int i = 0;i < M;i++){
        if(count[i] == 1){
            wa += er[i];
        }
    }
  printf("%d %d", ac, wa);
    free(count);
  free(er);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int N, M, ac, wa, *count, d;
  char str[8];
  scanf("%d %d", &N, &M);
  ac = 0;
  wa = 0;
  count = (int *)malloc(N * sizeof(int));
  for(int i = 0; i < M;i++){
    scanf("%d %s", &d, str);
    if(strcmp(str, "WA") == 0 && count[d-1] != 1){
      wa += 1;
    }else if(strcmp(str, "AC") == 0 && count[d-1] != 1){
      ac += 1;
        count[d-1] = 1;
    }
  }
  printf("%d %d", ac, wa);
    free(count);
  return 0;
}


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, M] = nextIntArray()
    const ac = new Set()
    const judge = new Array(N).fill(false)
    const cnt = new Array(N).fill(0)
    let wa = 0
    while (hasNext()) {
        let [p, s] = nextStrArray()
        p = Number(p)-1
        if(judge[p]) continue
        if (s == "WA") {
            cnt[p]++
        }
        if (s == "AC") {
            ac.add(p)
            wa += cnt[p]
            judge[p] = true
        }
    }
    console.log(ac.size, wa)
}
Main()


/*
-------関数一覧--------
arr1dto2d(Array) 一次元配列を二次元配列にします
pf(N)素因数分解した結果をオブジェクトで返します
gcd(a,b)最大公約数を返します
lcm(a,b)最小公倍数を返します
num(a,b)a-bを返します。ソート用です
isPrime(n)素数かどうか真偽値で返します
isNumber(n)数かどうか真偽値で返します
arrsum(arr)配列の合計値を返します
nibu(arr,n)n以下で最も大きい数の添字を返します(nを含みます)
br(input)入力を改行で区切ります
*/
const debugMode = false;
const inf = Number.MAX_SAFE_INTEGER;
const mod = 1000000007;
function Main(input){
  input = input.split("\n");
  var mem = input[0].split(" ").map(Number);
  var arr = new Array(mem[0]+1).fill(false);
  var sum = new Array(mem[0]+1).fill(0);
  input.shift()
  input.forEach(function(val){
      var mem = val.split(" ");
      mem[0] = Number(mem[0]);
      if(!arr[mem[0]]){
          if(mem[1]=="AC"){
              arr[mem[0]] = true;
          }else{
              sum[mem[0]]++;
          }
      }
  });
  var p = 0;
  var ac = 0;
  for(var i=1;i<arr.length;i++){
      if(arr[i]){
          ac++;
          p += sum[i];
      }
  }
  console.log(ac+" "+p)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function zisyozyunn(a){
  var arr = [];
  for(var i=0;i<input[0];i++){
    arr.push(i+1);
  }
  var sum = 0;
  for(var i=0;i<a.length;i++){
    var f = arr.findIndex(val => val==a[i]);
    sum += factorialize(a.length-1-i)*f;
    arr.splice(f,1);
  }
  return sum;
}
function arrsum(arr){
  var sum = 0;
  for (var i=0,len=arr.length; i<len; ++i) {
      sum += arr[i]-0;
  };
  return sum;
}
function debug(val){
  if(debugMode==true){
    console.log(val)
  }
}
function arrMaxPoint(arr){
	var max = Number.MIN_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(max<arr[i]){
			max = arr[i];
			point = i;
		}
	}
	return point;
}
function arrMinPoint(arr){
	var min = Number.MAX_SAFE_INTEGER;
	var point = -1;
	for(var i=0;i<arr.length;i++){
		if(min>arr[i]){
			min = arr[i];
			point = i;
		}
	}
	return point;
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}
function isNumber(val){
	const pat = /^([1-9]\d*|0)$/;
	return pat.test(val);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
		arr[i]=arr[i].split("");
		}
	return arr;
}
function factorialize(num) {
  if (num === 0) { return 1; }
  return num * factorialize(num-1);
}
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}
function rotate(array) {
  const ROW = array.length;
  const COL = array[0].length;
  const row = ROW-1;
  var a = new Array(COL);
  for (var c=0; c<COL; c++) {
    a[c] = new Array(ROW);
    for (var r=0; r<ROW; r++) {
      a[c][r] = array[row-r][c];
    }
  }
  return a;
}
function part_in(base,push,st){
	for(var i=st,p=0;p<push.length;i++,p++){
		base[i] = push[p];
	}
	return base;
}
function part_reverse(arr,s,g){
	var push = arr.slice(s-1,g);
  push.reverse();
	arr = part_in(arr,push,s-1);
	return arr;
}
function zeroPadding(num,length){
    return (num + '000000000000000000000000000000000').slice(0,length);
}
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i]-0;
    };
    return sum;
}
function pf(n) {
    var result = {};

    if (n === 1) {
        return {"1":1}
    }

    var init = 2;

    while (n !== 1) {
        var i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i === 0) {
                n /= i;
                if (!(result[i] > 0)) {
                    result[i] = 0;
                }
                result[i]++;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n
    return a * b / g(a, b)
}
function num(a, b) {
  return a - b;
}
function nibu(a,searchValue){
	var index = -1;

//調べる左端を表す添字(index)
var left = 0;

//調べる右端を表す添字(index)
var right = a.length-1;

//左端と右端にデータがある間は処理を繰り返す
while(left <= right){

    //左右の真ん中を表す添字(index)
    middle =Math.floor((left +right)/2);

    //真ん中の値と探す値を比較する
    if(a[middle]==searchValue){
        //一致した場合、変数に入れて処理終了
        index = middle;
        break;
    }else if(a[middle]<searchValue){
        //探す値より小さい場合、左側にはもっと小さい値しかないので左端の値を真ん中の値の右に移動する
        left = middle +1;
    }else{
        //探す値より大きい場合、右側にはもっと大きい値しかないので右端の値を真ん中の値の左に移動する
        right = middle -1;
    }
}
if(index!=-1) return index;
else return left;
}
function br(input){
  return input.split("\n");
}
function is_sortred(arr){
  var flag = true;
  for(var i=1;i<arr.length;i++){
    if(arr[i-1]>arr[i]){
      flag = false;
      break;
    }
  }
  return flag;
}
function primeFactorization(n) {

	// 平方根を保存
	var s = Math.floor(Math.sqrt(n));

	var r = 0;

	var result = {};

	// 2から平方根までの素因数を求める
	for (var i = 2;i <= s;i++) {

		if ((n % i) == 0) {

			r = 0; // 指数カウンタクリア

			do {

				r++; // 指数カウンタプラス

				n = n / i;

			} while ((n % i) == 0);

			// 素因数iを指数とともに保存
			result[i]=r;

		}

	}

	// 残った素数を追加
	if (n > s) {
		result[n] = 1;
	}

	return result;

}


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, M] = nextIntArray()
    const ac = new Set()
    const judge = {}
    const cnt = {}
    let wa = 0
    while (hasNext()) {
        let [p, s] = nextStrArray()
        if(judge[p] && judge[p] == "AC") continue
        else {
            if (s == "WA") {
                cnt[p] ? cnt[p]++ : cnt[p] = 1
                judge[p] = "WA"
            }
            if (s == "AC") {
                ac.add(p)
                judge[p] = "AC"
                if(cnt[p]) wa += cnt[p]
            }
        }

    }
    console.log(ac.size, wa)
}
Main()


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, M] = nextIntArray()
    const ac = new Set()
    const m = {}
    let wa = 0
    while (hasNext()) {
        let [p, s] = nextStrArray()
        if (s == "WA") {
            if(!m[p]) m[p] = 1
            else if(m[p] !== -1) m[p]++
        }
        if (s == "AC") {
            ac.add(p)
            if(m[p] && m[p] !== -1){
                wa += m[p]
                m[p] = -1
            }
        }
    }
    console.log(ac.size, wa)
}
Main()


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, M] = nextIntArray()
    const ac = new Set()
    const m = new Map()
    let wa = 0
    while (hasNext()) {
        let [p, s] = nextStrArray()
        if (s == "WA" && (!m[p]||m[p] !== -1)) {
            if(!m[p]) m[p] == 1
            else m[p]++
        }
        if (s == "AC") {
            ac.add(p)
            if(!m[p] && m[p] !== -1){
                wa += m[p]
                m[p] = -1
            }
        }
    }
    console.log(ac.size, wa)
}
Main()


"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function () { return this.index < this.max },
        "next": function () { if (!this.hasNext()) { throw "ArrayIndexOutOfBoundsException"; } else { return this.list[this.index++]; } }
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const [N, M] = nextIntArray()
    const ac = new Set()
    const m = new Map()
    let wa = 0
    while (hasNext()) {
        let [p, s] = nextStrArray()
        if (s == "WA" && !m[p]) {
            wa++
        }
        if (s == "AC") {
            ac.add(p)
            m[p] = -1
        }
    }
    console.log(ac.size, wa)
}
Main()


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a, w := make([]int, n, n), make([]int, n, n)
	for i := 0; i < n; i++ {
		a[i], w[i] = 0, 0
	}

	sc.Scan()
	m, _ := strconv.Atoi(sc.Text())

	ac, wa := 0, 0
	for i := 0; i < m; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		s := sc.Text()

		if a[p-1] == 1 {
			continue
		}

		if s == "AC" {
			ac++
			a[p-1] = 1
			wa += w[p-1]
		} else {
			w[p-1]++
		}
	}

	fmt.Println(ac, wa)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := getInt(), getInt()
	ac := make([]bool, N)
	wa := make([]int, N)
	ans := 0
	miss := 0
	for i := 0; i < M; i++ {
		p, s := getInt()-1, getString()
		if ac[p] == false {
			if s == "AC" {
				ac[p] = true
				miss += wa[p]
				ans++
			} else {
				wa[p]++
			}
		}
	}
	out(ans, miss)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	a := make([]int, n)
	ac, wa := 0, 0
	for i := 0; i < m; i++ {
		p := nextInt()
		s := next()

		if a[p-1] == -1 {
			continue
		}
		if s == "WA" {
			a[p-1]++
		} else {
			ac++
			wa += a[p-1]
			a[p-1] = -1
		}
	}

	fmt.Println(ac, wa)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n, m int
	n, m = nextInt(), nextInt()
	Ac, Wa := make(map[int]bool, n), make([]int, n)
	Acount, Wcount := 0, 0
	for i := 0; i < m; i++ {
		p, s := nextInt(), nextStr()
		if Ac[p] {
			continue
		}
		if s == "AC" {
			Ac[p] = true
			continue
		}
		Wa[p]++
	}
	for i := 0; i < n; i++ {
		if Ac[i] {
			Acount++
			Wcount += Wa[i]
		}
	}
	fmt.Println(Acount, Wcount)

}

func init() {
	const max = 1024
	var buf = make([]byte, max)
	sc.Buffer(buf, max)
	sc.Split(bufio.ScanWords)
	return
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n, m := readI(), readI()
	acp := make(map[int]bool)
	ac := 0
	ngp := make(map[int]int)
	for i := 0; i < m; i++ {
		p, s := readI(), readS()
		if !acp[p] {
			if s == "AC" {
				acp[p] = true
				ac++
			} else {
				ngp[p]++
			}
		}
	}
	n = n + 1
	ng := 0
	for _, v := range ngp {
		ng += v
	}
	fmt.Println(ac, ng)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n, m := readI(), readI()
	acp := make(map[int]bool)
	ac := 0
	ng := 0
	for i := 0; i < m; i++ {
		p, s := readI(), readS()
		if s == "AC" {
			if !acp[p] {
				acp[p] = true
				ac++
			}
		} else {
			if !acp[p] {
				ng++
			}
		}
	}
	n = n + 1
	fmt.Println(ac, ng)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


# frozen_string_literal: true

def cin
  gets.split.map(&:to_i)
end

N, M = cin

ac = wa = 0
misses = Array.new(N + 1, 0)

M.times do
  p, s = gets.split
  p = p.to_i

  next if misses[p] == -1

  if s == 'WA'
    misses[p] += 1
  elsif s == 'AC'
    ac += 1
    wa += misses[p]
    misses[p] = -1
  end
end
puts "#{ac} #{wa}"


# frozen_string_literal: true

def cin
  gets.split.map(&:to_i)
end

N, M = cin

ac = pena = 0
misses = Array.new(N + 1, 0)

M.times do
  p, s = gets.split
  p = p.to_i

  next if misses[p] == -1

  if s == 'WA'
    misses[p] += 1
  elsif s == 'AC'
    ac += 1
    pena += misses[p]
    misses[p] = -1
  end
end

puts "#{ac} #{pena}"


N, M = gets.split.map(&:to_i)

a = Array.new(N + 1, 0)
pt, pn = 0, 0
M.times do
  p, s = gets.split
  p = p.to_i
  next if a[p] == -1
  if s == 'AC'
    pn += a[p]
    pt += 1
    a[p] = -1
  elsif s == 'WA'
    a[p] += 1
  end
end
puts "#{pt} #{pn}"


n,m=gets.split.map(&:to_i)
hash={}
m.times do |i|
    p,s=gets.split
    if hash[p]==nil
        hash[p]=[s]
    else
        hash[p]<<s
    end
end

ac=0
penalty=0
hash.each_value do |s|
    wa=0
    s.each do |i|
        if i=="AC"
            ac+=1
            penalty=wa
            break
        else
            wa+=1
        end
    end
end

puts "#{ac} #{penalty}"


n,m=gets.split.map(&:to_i)
hash={}
m.times do |i|
    p,s=gets.split
    if hash[p]==nil
        hash[p]=[s]
    else
        hash[p]<<s
    end
end

ac=0
wa=0
hash.each_value do |s|
    s.each do |i|
        if i=="AC"
            ac+=1
            break
        else
            wa+=1
        end
    end
end

puts "#{ac} #{wa}"


N,M = gets.strip.split.map(&:to_i)
array = []
M.times do  #この書き方を覚えよ！！！！、型が別の場合
  j, result = gets.strip.split
  j = j.to_i
  result = result.to_s
  array << [j,result]
end
#入力完了
good = 0
bad = 0
#最後はこれを出力する
for i in 1..N
  k = 0
  m = 0
  s = 0
  while k < M
    if array[k][0] == i
      if array[k][1] == "WA"
        m += 1
      else
        s += 1
        break
      end
    end
    k += 1
  end
  if s == 1
    bad += m
    good += 1
  end
end
puts [good, bad].join(" ")


fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut answered = 0;
    let mut penalty = 0;
    let mut penalties = vec![0; n + 1];
    for _ in 0..m {
        let p: usize = iter.next().unwrap().parse().unwrap();
        let r = iter.next().unwrap();
        if r == "AC" {
            if penalties[p] != -1 {
                answered += 1;
                penalty += penalties[p];
            }
            penalties[p] = -1;
        } else {
            if penalties[p] != -1 {
                penalties[p] += 1;
            }
        }
    }
    format!("{} {}\n", answered, penalty)
}


use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: i32 = iter.next().unwrap().parse().unwrap();

    let mut accepted = vec![false; n];
    let mut penalty = vec![0; n];
    let mut accepted_num = 0;
    let mut penalty_num = 0;

    let mut a = Vec::new();
    a.push(1);
    for _i in 0..m {
        let p: usize = iter.next().unwrap().parse::<usize>().unwrap() - 1;
        let s: &str = iter.next().unwrap();
        if accepted[p] {
            continue;
        }
        if s == "AC" {
            accepted[p] = true;
            penalty_num += penalty[p];
            accepted_num += 1;
        } else {
            penalty[p] += 1;
        }
    }

    println!("{} {}", accepted_num, penalty_num);
}


use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut accepted = vec![false; n + 1];
    let mut warnings = vec![0; n + 1];

    let mut accepts: usize = 0;
    let mut penalties: usize = 0;
    for _ in 0..m {
        let p: usize = iter.next().unwrap().parse().unwrap();
        let s: &str = iter.next().unwrap();

        if s == "AC" && accepted[p] == false {
            accepted[p] = true;
            accepts += 1;
            penalties += warnings[p];
        }
        if s == "WA" {
            warnings[p] += 1;
        }
    }

    return format!("{} {}", accepts, penalties);
}

#[test]
fn test() {
    assert_eq!(solve(r"2 5
    1 WA
    1 AC
    2 WA
    2 AC
    2 WA"), "2 2");
    assert_eq!(solve(r"100000 3
    7777 AC
    7777 AC
    7777 AC"), "1 0");
    assert_eq!(solve(r"6 0"), "0 0");
}


use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut v: Vec<(bool, u32)> = vec![(false, 0); n];
    let (ac, wa);

    for _ in 0..m {
        let (p, s): (usize, String) = parse_line().unwrap();
        match s.as_str() {
            "AC" => {
                if !v[p - 1].0 {
                    v[p - 1].0 = true;
                }
            }
            "WA" => {
                if !v[p - 1].0 {
                    v[p - 1].1 += 1;
                }
            }
            _ => unreachable!(),
        }
    }
    ac = v.iter().filter(|x| x.0).count();
    wa = v.iter().fold(0, |x, y| x + y.1);
    println!("{} {}", ac, wa);
}


use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let mut a = vec![0; n];
    let mut w = vec![0; n];
    for _ in 0..m {
        let x:usize = read();
        let s:String = read();
        let x = x - 1;
        if a[x] == 0 && s == "WA" {
            w[x] += 1;
        }
        if s == "AC" {
            a[x] = 1;
        }
    }
    println!(
        "{} {}",
        a.iter().sum::<usize>(),
        w.iter().sum::<usize>()
    );
}


use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize, m: usize};

    let mut r_ac = vec![0; n];
    let mut r_wa: Vec<i128> = vec![0; n];

    let mut ac_count = 0;
    let mut wa_count = 0;

    for _ in 0..m {
        input! {p: usize, s: String};

        let index = p - 1;

        if r_ac[index] == 0 {
            if s == "AC" {
                r_ac[index] = 1;
            // ac_count += 1;
            // wa_count += r_wa[index];
            } else {
                r_wa[index] += 1;
            }
        }
    }

    // print!("{} {}", r_ac.iter().sum::<usize>(), wa_count)
    print!(
        "{} {}",
        r_ac.iter().sum::<usize>(),
        r_wa.iter().sum::<i128>()
    );
}


// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])

    var aryAC = [Bool](repeating: false, count: n)
    ///誤答した問題の数
    var aryWA = [Int](repeating: 0, count: n)

    for _ in 0..<m {
        let ps = readLine()!.split(separator: " ").map { String($0) }
        let (p, s) = (Int(ps[0])! - 1, ps[1])

        if s == "AC" {
            aryAC[p] = true
        }
        if !aryAC[p] {
            aryWA[p] += 1
        }
    }

    var ACCounter = 0
    var WACounter = 0
    for i in 0..<n{
        if aryAC[i] {
            ACCounter += 1
            WACounter += aryWA[i]
        }
    }
    print(ACCounter,WACounter)
}
    main()


let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let ( n, m ) = ( arr[0], arr[1] )

var i = 0
var p = 0
var c = 0

var ac = Array(count: n, repeatedValue: 0)
var w = Array(count: n, repeatedValue: 0)
for i in 0..<m {
  let arr1=readLine()!.characters.split{$0==" "}.map{String($0)}

  var q: Int! = Int(arr1[0])! - 1
  if (ac[q] == 1 ) {
    continue
  }
  if (arr1[1] == "AC") {
    p += w[q]
    ac[q] = 1
    c += 1
    continue
  } else {
    w[q] += 1
  }
}

print(c,p)


// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    ///正答した問題の配列
    var aryAC = [String]()
    ///誤答した問題の数
    var aryWA = [Int](repeating: 0, count: n)
    ///フラグ(ACであればTrue)
    var ACCount = 0
    var WACount = 0
    ///WAを数えるカウンター(ACが出た場合、WACounterに加算しリセットする)
    for i in 0..<m {
        let ps = readLine()!.split(separator: " ").map { String($0) }
        let (p, s) = (ps[0], ps[1])

        if s == "AC" {
            if aryAC.firstIndex(of: p) == nil {
                // 初めて正答した場合の処理
                aryAC.append(p)
                ACCount += 1
                WACount += aryWA[Int(p)!-1]
            }

        } else {
            aryWA[Int(p)!-1] += 1
        }
    }
    print(ACCount, WACount)
}

main()


// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    ///正答した問題の配列
    var aryAC = [String]()
    ///フラグ(ACであればTrue)
    var isAC = false
    var ACCount = 0
    var WACount = 0
    ///WAを数えるカウンター(ACが出た場合、WACounterに加算しリセットする)

    var counter = 0
    for i in 0..<m {
        let ps = readLine()!.split(separator: " ").map { String($0) }
        let (p, s) = (ps[0], ps[1])
        isAC = s == "AC"
        if isAC {
            if aryAC.firstIndex(of: p) == nil {
                aryAC.append(p)
                ACCount += 1
            }
            WACount += counter
            counter = 0
        } else {
            counter += 1
        }
    }
    print(ACCount, WACount)
}
//____________________________________________________________________ここまで入

main()


// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryQuestionNo = [String]()
    var aryJudge = [String]()
    for _ in 0..<m {
        let ps = readLine()!.split(separator: " ").map { String($0) }
        let (p, s) = (ps[0], ps[1])
        aryQuestionNo.append(p)
        aryJudge.append(s)
    }
    //____________________________________________________________________ここまで入力
    ///正答した問題の配列
    var aryAC = [String]()
    ///フラグ(ACであればTrue)
    var isAC = false
    var ACCount = 0
    var WACount = 0
    ///WAを数えるカウンター(ACが出た場合、WACounterに加算しリセットする)
    var counter = 0

    for i in 0..<m {
        isAC = aryJudge[i] == "AC"
        if isAC {
            if aryAC.firstIndex(of: aryQuestionNo[i]) == nil {
                aryAC.append(aryQuestionNo[i])
                ACCount += 1
            }
            WACount += counter
            counter = 0
        } else {
            counter += 1
        }
    }
    print(ACCount, WACount)
}

main()


const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let [n,m]=tnn(2),p=[],k=[],save=new Array(n+1),wa=0,ac=0
  save.fill(0)
  for(let i=0;i<m;i++){
    p.push(tn())
    k.push(ts())
  }
  for(let i=0;i<m;i++){
    if(save[p[i]]==-1)continue
    if(k[i]=='WA'){
      save[p[i]]++
    }
    else if(k[i]=='AC'){
      ac++
      wa+=save[p[i]]
      save[p[i]]=-1
    }
  }
  to(ac,wa)
}
main()


const main = (input) => {
  const lines = input.trim().split("\n");
  const [N, M] = lines[0].split(' ').map(str => parseInt(str));
  const waCount = new Array(N).fill(0);
  const isAC = new Array(N).fill(false);
  let waSum = 0;

  lines.slice(1).forEach(line => {
    let [p, s] = line.split(' ');
    p = parseInt(p) - 1;
    if (s === 'AC' && !isAC[p]) {
      isAC[p] = true;
      waSum += waCount[p];
    } else {
      waCount[p]++;
    }
  });

  const acSum = isAC.filter(bool => bool).length;

  console.log(acSum + ' ' + waSum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const [n,m]: number[] = input[0].split(' ').map((x: string): number => +x);
const ps = [];
for(let i=0;i<m;i++){
	ps.push(input[i+1].split(" "));
}

let AC: number = 0;
let WA: number = 0;
let li: number[] = new Array(n+1);
for(let i = 0; i<n+1; i++){
    li[i] = 0;
}

for(let i = 0; i < m; i++){
    const id = parseInt(ps[i][0]);
    if ( li[id] === -1 ){ continue; }
    if ( ps[i][1] ==='WA'){
        li[id] += 1;
    }else if( ps[i][1] ==='AC'){
        AC++;
        WA += li[id] || 0;
        li[id] = -1;
    }
}
console.log(AC, WA);


function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const m = parseInt(params1[1]);
  const p = lines.slice(1, m + 1).map(x => x.split(' ')[0]).map(x => parseInt(x));
  const s = lines.slice(1, m + 1).map(x => x.split(' ')[1]);

  let record = new Set();
  let accept = 0;
  let penalty = 0;
  for (let i = 0; i < m; i++) {
    if (!record.has(p[i])) {
      if (s[i] === 'AC') {
        record.add(p[i]);
        accept++;
      } else {
        penalty++;
      }
    }
  }
  console.log(`${accept} ${penalty}`);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(input: string) {
  const lines: string[] = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const m = parseInt(params1[1]);
  const p = lines.slice(1, m + 1).map(x => x.split(' ')[0]).map(x => parseInt(x));
  const s = lines.slice(1, m + 1).map(x => x.split(' ')[1]);

  let record: {[n: number]: boolean} = {};
  let accept = 0;
  let penalty = 0;
  for (let i = 0; i < m; i++) {
    if (!record[p[i]]) {
      if (s[i] === 'AC') {
        record[p[i]] = true;
        accept++;
      } else {
        penalty++;
      }
    }
  }
  console.log(`${accept} ${penalty}`);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


const main = (input: string) => {
  const lines = input.trim().split("\n")
  const PS = lines.slice(1).map(line => line.split(" "))
  const ACList = new Set()
  let WACount = 0

  PS.forEach(ps => {
    if(ps[1] === "AC") {
      ACList.add(ps[0])
    } else if (!ACList.has(ps[0])) {
      WACount += 1
    }
  })

  console.log(ACList.size + " " + WACount)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


A,B=map(int,input().split())
print(A+B if B%A==0 else B-A)


A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(B-A)


a,b = map(int,input().split())
if b % a == 0:
  print(a + b)
else:
  print(b-a)


a,b=map(int,input().split(" "))
print([a+b,b-a][b%a])


A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(A-B)


A,B=map(int(input().split()))
if B%A==0:
    print(A+B)
else:
    print(A-B)


import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();

		System.out.println(B%A==0?A+B:B-A);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}


import java.io.*;
import java.util.*;
import java.math.*;
// import java.awt.Point;

public class Main {
    InputStream is;
    PrintWriter out;
    String INPUT = "";

    static int mod = 1_000_000_007;
    // int mod = 998244353;
    long inf = Long.MAX_VALUE/2;

    void solve(){
        int a = ni();
        int b = ni();
        if(b%a==0){
            out.println(a+b);
            return;
        }
        else{
            out.println(b-a);
        }

    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    private static long lcm(long m, long n) {
        return m * (n /gcd(m, n));
    }

    void run() throws Exception
    {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        out.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
    }

    public static void main(String[] args) throws Exception { new Main().run(); }

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte()
    {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }

    private String ns()
    {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b) && b != ' ')){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n)
    {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }

    private int[] na(int n)
    {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }

    private int ni()
    {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl()
    {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] input = br.readLine().split(" ");
            int numberA = Integer.parseInt(input[0]);
            int numberB = Integer.parseInt(input[1]);

            int result = numberB - numberA;
            if (numberB % numberA == 0) {
                result = numberA + numberB;
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b%a == 0)
            System.out.println(a+b);
        else
            System.out.println(a-b);

    }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    if ((b % a) == 0) {
      System.out.println(a + b);
    } else {
      System.out.println(a - b);
    }

  }
}


import java.util.*;

public class Main{
	public static main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0) {
          System.out.println(A + B);
        } else {
          System.out.println(B - A);
        }
    }
}


#include <cstdio>

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d\n", b % a == 0 ? a + b : b - a);
  return 0;
}


#include<stdio.h>
int main()
{
	int A,B;
	scanf("%d%d", &A,&B);
	if(B%A==0)
	{
		printf("%d", A+B);
	}
	else
	printf("%d", B-A);
	return 0;
}


#include <iostream>

using namespace std;

int main() {
  int a, b;

  cin >> a >> b;

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


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    int a, b;
    cin >> a >> b;
    if (a%b == 0) cout << a+b << endl;
    else cout << b-a << endl;
    return 0;
}


#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;

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


#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;

// dijkstra
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
// dijkstra end

class UnionFind
{
public:
  ll par[100005];
  ll depth[100005];
  ll nGroup[100005];

  UnionFind(ll n) {
    init(n);
  }

  void init(ll n) {
    for(ll i=0; i<n; i++) {
      par[i] = i;
      depth[i] = 0;
      nGroup[i] = 1;
    }
  }

  ll root(ll x) {
    if(par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(ll x, ll y) {
    return root(x) == root(y);
  }

  void unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if(x == y) return;

    if(depth[x] < depth[y]) {
      par[x] = y;
      nGroup[y] += nGroup[x];
      nGroup[x] = 0;
    } else {
      par[y] = x;
      nGroup[x] += nGroup[y];
      nGroup[y] = 0;
      if(depth[x] == depth[y])
        depth[x]++;
    }
  }
};
// unionfind end

// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// nCr end

// tree DP
vector<ll> depth;
vector<ll> f;
vector<ll> g;
void dfs(const Graph &G, ll v, ll p, ll d) {
    depth[v] = d;
    for (auto nv : G[v]) {
        if (nv == p) continue;
        dfs(G, nv, v, d+1);
    }

    f[v] = 1;
    g[v] = 1;
    for (auto c : G[v]) {
        if (c == p) continue;
        f[v]*=g[c];
        f[v]%=MOD;
        g[v]*=f[c];
        g[v]%=MOD;
        }
    f[v]+=g[v];
    f[v]%=MOD;
}
// tree DP end

template<ll MOD> struct Fp {
    ll val;
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr ll getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint calc(ll N, ll K) {
    mint res = 1;
    for (ll n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
mint COM(ll n, ll k){
    if (k == 0) return 1;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0){
    cout<< a+b <<endl;}
    else cout<< a - b <<endl;
  return 0;
    }


#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d", &a, &b);

  if(b%a){
    printf("%d", b-a);
  }
  else{
    printf("%d", a+b);
  }

}


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

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    if (B % A == 0) {
        printf("%d", A+B);
    } else {
        printf("%d", B-A);
    }
}


#include<stdio.h>

int main(){
	int a,b,c;

  	scanf("%d",&a);

  	scanf("%d",&b);

 	if(b % a == 0){
		c = a + b;
    }else{
		c = b - a;
    }

  	printf("%d",c);
	return 0;

}


#include <stdio.h>

int main(){
	int A, B;
	scanf("%d %d");
	printf("%d\n", (B%A == 0) ? A+B : B-A);

	return 0;
}


#include <stdio.h>

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	if(B%A == 0){
		printf("&d", A + B);
	}
	else{
		printf("&d", B - A);
	}

	return 0;
}


#include <stdio.h>

int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	if(B % A == 0){
		printf("&d", A + B);
	}
	else{
		printf("&d", B - A);
	}

	return 0;
}


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  if(B % A == 0){
     myout(A + B);
  }else{
     myout(B - A);
  }
}


var stdin = require("fs").readFileSync("/dev/stdin", "utf8");
stdin = stdin.trim().split("\n").reverse();
function input(){return stdin.pop()}
var stdout = [];

var x = input().split(" ").map(n=>parseInt(n));
var a = x[0]
var b = x[1]
if (b % a){
    stdout.push(b - a)
}else{
    stdout.push(b + a)
}

stdout = stdout.join(" ");
console.log(stdout);


// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	ab = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(ab[0], 10);
	var b = parseInt(ab[1], 10);
   if (b%a == 0){console.log(a+b);}else{console.log(b-a);}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function main(input){
    ab=input.split(' ')
    a=parseInt(ab[0],10)
    b=parseInt(ab[1],10)
    if (a%b==0){
        console.log(a+b)

    }else{
        console.log(b-a)

    }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


function main(input){
    ab=input.split(' ')
    a=parseInt(ab[0],10)
    b=parseInt(ab[1],10)
    if (a/b==0){
        console.log(a+b)

    }else{
        console.log(b-a)

    }

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  if(B % A == 0){
     myout(A + B);
  }else{
     myout(A - B);
  }
}


package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  ans := b - a
  if b % a == 0 {ans = a + b}
  fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strconv"
	"strings"
	// "regexp"
)

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	A, B := readInt(), readInt()
	if B%A == 0 {
		fmt.Println(A + B)
	} else {
		fmt.Println(B - A)
	}
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func readString() (read string) {
	scanner.Scan()
	read = scanner.Text()
	return
}

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func max(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans < v {
			ans = v
		}
	}
	return ans
}
func min(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans > v {
			ans = v
		}
	}
	return ans
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}


package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(a + b)
	}
}


a, b = gets.split.map(&:to_i)

if b%a == 0
    puts (a+b)
else
    puts (b-a)
end


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := getInt(), getInt()

	if a%b == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}


A,B = gets.split.map(&:to_i)
puts B%A==0 ? A+B : B-A


a,b=gets.split.map(&:to_i);p b % a == 0 ? a + b : b - a


a, b = gets.split("\s").map(&:to_i)

p b % a == 0 ? a+b : b-a


a,b=gets.split.map(&:to_i)
p (a%b==0)?(a + b):(b-a)


a,b=gets.split.map(&:to_i)
p (a%b==0)?a + b:b-a


a, b = gets.chomp.split.map(&:to_i)

ans = (b / a) % a

if ans == 0
  puts b + a
else
  puts b - a
end


use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	if b%a == 0 {
		println!("{}", a+b);
	}else{
		println!("{}", b-a);
	}
}


use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_tuple();
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }
}


#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    if b % a == 0 {
        println!("{}", a+b);
    } else {
        println!("{}", b-a);
    }
}


//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (a, b): (usize, usize);
    input!(a, b);
    if a % b == 0 {
        p(a + b);
    } else {
        p(a - b);
    }
}


(a, b) = map(int, input().split())
if b % a == 0:
    print(a + b)
else:
    print(b - a)


fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a = read(&mut stdin_lock, &mut buf, b' ');
    let b = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}{}", a, b);
    println!("{}", solve(a, b));
}

fn solve(a: i32, b: i32) -> i32 {
    if b % a == 0 {
        a + b
    } else {
        b - a
    }
}

#[test]
fn example1() {
    assert_eq!(16, solve(4, 12))
}

#[test]
fn example2() {
    assert_eq!(12, solve(8, 20))
}

#[test]
fn example3() {
    assert_eq!(2, solve(1, 1))
}


import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let a = Int(input[0])!
let b = Int(input[1])!

if b % a == 0 {
  print(a+b)
} else {
  print(b-a)
}


import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let a = Int(input[0])
let b = Int(input[1])

if b % a == 0 {
  print(a+b)
} else {
  print(b-a)
}


import Foundation

let input = readLine()!.componentsSeparatedByString(" ")
let a = input[0]
let b = input[1]

if b % a == 0 {
  print(a+b)
} else {
  print(b-a)
}


export class Main {
  static main(input: string): string {
    const tmp = input.split("\n");
    const [a, b] = tmp[0].split(" ").map(Number);
    return `${b + (b % a == 0 ? 1 : -1) * a}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


((input: string): void => {
    const [a, b]: number[] = input.split(" ").map(Number);
    console.log(b%a==0 ? a+b : b-a);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));


function Main(raw) {
  const input = raw.split(/ |\n/);
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  const ans= (B%A==0)?A+B:B-A;
  //出力
  console.log("%d", ans);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result}

const main = ()=>{
  let[a,b]=nrin(2);
  a%b===0?out(a+b):out(b-a);
}
main();


function Main(args){
    const input=args.split(" ");
    const A=parseInt(input[0]);
    const B=parseInt(input[0]);
    const ans=B%A==0?A+B:B-A;
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


function Main(raw: string) {
  const input = raw.split([" ","\n"]);
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  const ans= (B%A==0)?A+B:B-A;
  //出力
  console.log("%d", ans);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [x1]
    for i in a[:-1]:
        x.append(2 * i - x[-1])
    ans = ' '.join(map(str, x))
    print(ans)

if __name__ == '__main__':
    main()


# ABC133D - Rain Flows into Dams
def main():
    # X_0 = sum(A) - 2 * sum(A[1::2]), X_i = 2Ai - X_{i-1}
    N, *A = map(int, open(0).read().split())
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(" ".join(map(str, X)))

if __name__ == "__main__":
    main()


def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    X = [0] * N
    cur = sum(A) - 2 * sum(A[1::2])
    X[0] = cur
    for i, a in enumerate(A[:-1], 1):
        X[i] = a * 2 - cur
        cur = X[i]
    print(' '.join(map(str, X)))

if __name__ == "__main__":
    main()


n=int(input())
a=list(map(int,input().split()))
b=[0]*n
x=-1
y=2*10**9
z=(x+y)//2
for i in range(1000):
    b[0]=z
    for j in range(1,n):
        b[j]=a[j-1]*2-b[j-1]
    if b[0]+b[-1]>2*a[-1]:
        y=z
        z=(x+y)//2
    elif b[0]+b[-1]<2*a[-1]:
        x=z
        z=(x+y)//2
    else:
        break
print(*b)


import numpy as np

N = int(input())
A = list(map(int, input().split()))

coef_mat = np.matrix([[1 if (i == j or i + 1 == j or (i + 1 == N and j == 0)) else 0 for j in range(N) ] for i in range(N)])**(-1)
vec = np.matrix([A]).T
res = coef_mat @ vec

for i in range(N):
    print(int(res[i, 0]) * 2)


def nCk(_n,_k):
  if _k==0:
    return 1
  else:
    if _n<0 or _k<0 or _n-_k<0:
      return 0
    else:
      return (fact[_n]//(fact[_k]*fact[_n-_k]))%m

fact=[1]*2005
for i in range(1,2001):
  fact[i]=fact[i-1]*i

n,k=map(int,input().split())
m=10**9+7
ans=cnt=0
for _k in range(1,k+1):
  ans=(nCk(n-k+_k,_k)-cnt)*nCk(k-1,_k-1) if _k>1 else n-k+_k
  cnt+=ans
  cnt%=m
  ans%=m
  print(ans)


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        boolean local = false;
        boolean async = false;

        Charset charset = Charset.forName("ascii");

        FastIO io = local ? new FastIO(new FileInputStream("D:\\DATABASE\\TESTCASE\\Code.in"), System.out, charset) : new FastIO(System.in, System.out, charset);
        Task task = new Task(io, new Debug(local));

        if (async) {
            Thread t = new Thread(null, task, "dalt", 1 << 27);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
            t.join();
        } else {
            task.run();
        }

        if (local) {
            io.cache.append("\n\n--memory -- \n" + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "M");
        }

        io.flush();
    }

    public static class Task implements Runnable {
        final FastIO io;
        final Debug debug;
        int inf = (int) 1e8;

        public Task(FastIO io, Debug debug) {
            this.io = io;
            this.debug = debug;
        }

        @Override
        public void run() {
            solve();
        }

        public void solve() {
            int n = io.readInt();
            long[] a = new long[n];
            long cum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = io.readInt();
                cum = a[i] - cum;
            }
            long x0 = cum / 2;
            long[] x = new long[n];
            x[0] = x0;
            for (int i = 1; i < n; i++) {
                x[i] = a[i - 1] - x[i - 1];
            }
            for (int i = 0; i < n; i++) {
                io.cache.append(x[i] * 2).append(' ');
            }
        }
    }

    /**
     * Mod operations
     */
    public static class Modular {
        int m;

        public Modular(int m) {
            this.m = m;
        }

        public int valueOf(int x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return x;
        }

        public int valueOf(long x) {
            x %= m;
            if (x < 0) {
                x += m;
            }
            return (int) x;
        }

        public int mul(int x, int y) {
            return valueOf((long) x * y);
        }

        public int mul(long x, long y) {
            x = valueOf(x);
            y = valueOf(y);
            return valueOf(x * y);
        }

        public int plus(int x, int y) {
            return valueOf(x + y);
        }

        public int plus(long x, long y) {
            x = valueOf(x);
            y = valueOf(y);
            return valueOf(x + y);
        }

        @Override
        public String toString() {
            return "mod " + m;
        }
    }

    public static class FastIO {
        public final StringBuilder cache = new StringBuilder();
        private final InputStream is;
        private final OutputStream os;
        private final Charset charset;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 8);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastIO(InputStream is, OutputStream os, Charset charset) {
            this.is = is;
            this.os = os;
            this.charset = charset;
        }

        public FastIO(InputStream is, OutputStream os) {
            this(is, os, Charset.forName("ascii"));
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public double readDouble() {
            boolean sign = true;
            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+';
                next = read();
            }

            long val = 0;
            while (next >= '0' && next <= '9') {
                val = val * 10 + next - '0';
                next = read();
            }
            if (next != '.') {
                return sign ? val : -val;
            }
            next = read();
            long radix = 1;
            long point = 0;
            while (next >= '0' && next <= '9') {
                point = point * 10 + next - '0';
                radix = radix * 10;
                next = read();
            }
            double result = val + (double) point / radix;
            return sign ? result : -result;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

        public int readLine(char[] data, int offset) {
            int originalOffset = offset;
            while (next != -1 && next != '\n') {
                data[offset++] = (char) next;
                next = read();
            }
            return offset - originalOffset;
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public int readString(byte[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (byte) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public char readChar() {
            skipBlank();
            char c = (char) next;
            next = read();
            return c;
        }

        public void flush() {
            try {
                os.write(cache.toString().getBytes(charset));
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public boolean hasMore() {
            skipBlank();
            return next != -1;
        }
    }

    public static class Debug {
        private boolean allowDebug;

        public Debug(boolean allowDebug) {
            this.allowDebug = allowDebug;
        }

        public void assertTrue(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (!flag) {
                fail();
            }
        }

        public void fail() {
            throw new RuntimeException();
        }

        public void assertFalse(boolean flag) {
            if (!allowDebug) {
                return;
            }
            if (flag) {
                fail();
            }
        }

        private void outputName(String name) {
            System.out.print(name + " = ");
        }

        public void debug(String name, int x) {
            if (!allowDebug) {
                return;
            }

            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, long x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, double x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, int[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, long[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, double[] x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.toString(x));
        }

        public void debug(String name, Object x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println("" + x);
        }

        public void debug(String name, Object... x) {
            if (!allowDebug) {
                return;
            }
            outputName(name);
            System.out.println(Arrays.deepToString(x));
        }
    }
}


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	private static final long M = 1000000007L;

	int pre[][];

	void solve() {
		StringBuffer sb = new StringBuffer();
		int n = ni();
		int[] a = na(n);

		long ans[] = new long[n];
		for (int i = 0; i < n; i++)
			ans[0] += (i % 2 == 0 ? 1 : -1) * a[i];

		for (int i = 1; i < n; i++)
			ans[i] = 2 * a[i - 1] - ans[i - 1];

		for (long i : ans)
			sb.append(i).append(' ');
		out.println(sb);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}