// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  int n, m; in(n),in(m);
  vector<bool> ac(n+1, false);
  vector<int> wa(n+1, 0);
  int p; string s;
  loop(i,0,m) {
    in(p),in(s);
    if (ac[p]) continue;
    if (s == "WA") wa[p]++;
    else ac[p] = true;
  }
  loop(p,1,n+1) if (!ac[p]) wa[p] = 0;
  
  int ans1 = 0;
  for (auto&&b: ac) ans1+=b;
  int ans2 = 0;
  for (auto&&w: wa) ans2+=w;
  print(ans1, " ");
  print(ans2);
  return 0;
}

#include"bits/stdc++.h"
using namespace std;
const int N=5e3+100;
typedef long long LL;
struct node{
	LL h,p;
}a[N];
LL dp[N];
bool cmp(node a,node b){
	if(a.h+a.p==b.h+b.p)return a.h<b.h;
	return a.h+a.p<b.h+b.p;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=5050;i++)dp[i]=0x3f3f3f3f3f3f3f3f;
	for(int i=1;i<=n;i++)
		scanf("%d %d",&a[i].h,&a[i].p);
	sort(a+1,a+n+1,cmp);
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=i-1;j>=0;j--){
			if(a[i].h>=dp[j]){
				dp[j+1]=min(dp[j+1],dp[j]+a[i].p);
			}
		}
	}
	int ans=1;
	for(int i=2;i<=n;i++)
		if(dp[i]!=0x3f3f3f3f3f3f3f3f)ans=i;
	printf("%d\n",ans);
}