#include <bits/stdc++.h>
using i8 = std::int8_t;using i16 = std::int16_t;using i32 = std::int32_t;using i64 = std::int64_t;using u8 = std::uint8_t;using u16 = std::uint16_t;using u32 = std::uint32_t;using u64 = std::uint64_t;using f32 = float;using f64 = double;
using vi32 = std::vector<i32>;using vu32 = std::vector<u32>;using vi64 = std::vector<i64>;using vu64 = std::vector<u64>;using vvi32 = std::vector<vi32>;using vvu32 = std::vector<vu32>;using vvi64 = std::vector<vi64>;using vvu64 = std::vector<vu64>;
using pi32 = std::pair<i32,i32>;using pu32 = std::pair<u32,u32>;using pi64 = std::pair<i64,i64>;using pu64 = std::pair<u64,u64>;using vpi32 = std::vector<pi32>;using vpu32 = std::vector<pu32>;using vpi64 = std::vector<pi64>;using vpu64 = std::vector<pu64>;using si32  = std::stack<i32>;using si64  = std::stack<i64>;using su32  = std::stack<u32>;using su64  = std::stack<u64>;using qi32  = std::queue<i32>;using qi64  = std::queue<i64>;using qu32  = std::queue<u32>;using qu64  = std::queue<u64>;
#define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i<i##_len; ++i)
#define RFOR(i,a,b) for(i64 i=(a), i##_len=(b); i>i##_len; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(i64 i=static_cast<i64>(n-1); i >= 0; --i)
#define REPS(i,n) for(i64 i=1LL; i<=static_cast<i64>(n); ++i)
#define RREPS(i,n) RFOR(i,n,0)
#define ALL(obj) (obj).begin(),(obj).end()
#define CLR(ar,val) memset(ar, val, sizeof(ar))
#define SZ(obj) (static_cast<i32>(obj.size()))
#define cauto const auto&
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define dump(x) cout << #x << " = " << (x) << endl
#define PRINT(obj) std::cout<<((obj))<<std::endl;
#define PutStr(str) std::cout<<((str));
#define PutStrLn(str) std::cout<<((str))<<std::endl;
#define PutStrSpace(str) std::cout<<((str))<<(" ");
const i32 dx[4]={1,0,-1,0};
const i32 dy[4]={0,1,0,-1};
const i32 INF32 = 0x3F3F3F3F;
const i64 INF64 = 0x3F3F3F3F3F3F3F3F;
template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
class range {
private:
    struct I {
        i32 x;
        i32 operator*() { return x; }
        bool operator!=(I& lhs) { return x < lhs.x; }
        void operator++() { ++x; }
    };
    I i, n;
public:
    explicit range(int n) : i({0}), n({n}) { }
    range(int i,int n) : i({i}), n({n}) { }
    I& begin() { return i; }
    I& end() { return n; }
};

struct IoSetup {
    IoSetup() {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
        std::cout << std::fixed << std::setprecision(10);
        std::cerr << std::fixed << std::setprecision(10);
    }
}iosetup;

inline i32 read() {
    i32 x = 0, f = 1;
    char ch = std::getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = std::getchar(); }
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = std::getchar();
    return x * f;
}
void put(i32 x) {
    if (x < 0) std::putchar('-'), x = -x;
    if (x >= 10) put(x / 10);
    std::putchar(x % 10 + '0');
}
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first >> p.second;return is; }
template<typename A, typename B> std::ostream &operator<<(std::ostream &os, const std::pair<A, B>& p) { os << p.first << ' ' << p.second;return os; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for(T& in : v) is >> in; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) { for(i32 i = 0; i < SZ(v); i++) os << v[i] << (i+1 != SZ(v) ? " " : ""); return os; }

i32 main() {
    using namespace std;
    string s, t; cin >> s >> t;
    i8 ans = 0;
    for (i32 i = 0; i < 3; i++) {
        if (s[i] == t[i]) ans += 1;
    }
    put(ans);
    return 0;
}

Measured memory_bytes: 256