#include <bits/stdc++.h>
using namespace std;

int a[7], temp[7];

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

    int n;
    cin >> n;
    string S, X;
    cin >> S >> X;

    a[0] = 1;
    for(int j = n - 1;j >= 0;--j) {
        if(X[j] == 'T') {
            for(int i = 0;i < 7;++i) 
                if(a[(i * 10) % 7] == 1 || a[(i * 10 + S[j] - '0') % 7] == 1) temp[i] = 1;
                else temp[i] = 0;
            for(int i = 0;i < 7;++i) a[i] = temp[i];
        }
        if(X[j] == 'A') {
            for(int i = 0;i < 7;++i) {
                if(a[(i * 10) % 7] == 1 && a[(i * 10 + S[j] - '0') % 7] == 1) temp[i] = 1;
                else temp[i] = 0;
            }
            for(int i = 0;i < 7;++i) a[i] = temp[i];
        }
    }
    cout << (a[0] == 1 ? "Takahashi" : "Aoki");
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}
int main(void){
  ll n;
  cin >> n;
  ll a[n],b[n],c[n],d[n],v=0;
  rep(i,n){
    cin >> a[i] >> b[i];
    v+=a[i];
    c[i]=a[i]+b[i];
    d[i]=c[i]+a[i];
  }
  sort(d,d+n);
  rep(i,n){
    v-=d[n-i-1];
    if(v<0){
      cout << i+1 << endl;
      return 0;
    }
  }
}