#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define stream(line) istringstream in((line))
#define endl "\n"
#define F first
#define S second
#define clr(a, d) memset((a),d,sizeof(a))
const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int M = 100 + 5;
void print_vector(vector<int> &v) {
for (ll i = 0; i < v.size(); ++i) {
cout << v[i] << " ";
}
cout << endl;
}
int main() {
fast
int tc = 1;
string s = "314159265358979323846264338327";
cin >> tc;
while (tc--) {
string t;
cin >> t;
int cnt =0;
for (int i = 0; i < t.size(); ++i) {
if(s[i] == t[i]){
cnt++;
}else{
break;
}
}
cout << cnt << endl;
}
return 0;
}
1354B - Ternary String | 122B - Lucky Substring |
266B - Queue at the School | 1490A - Dense Array |
1650B - DIV + MOD | 1549B - Gregor and the Pawn Game |
553A - Kyoya and Colored Balls | 1364A - XXXXX |
1499B - Binary Removals | 1569C - Jury Meeting |
108A - Palindromic Times | 46A - Ball Game |
114A - Cifera | 776A - A Serial Killer |
25B - Phone numbers | 1633C - Kill the Monster |
1611A - Make Even | 1030B - Vasya and Cornfield |
1631A - Min Max Swap | 1296B - Food Buying |
133A - HQ9+ | 1650D - Twist the Permutation |
1209A - Paint the Numbers | 1234A - Equalize Prices Again |
1613A - Long Comparison | 1624B - Make AP |
660B - Seating On Bus | 405A - Gravity Flip |
499B - Lecture | 709A - Juicer |