#include <bits/stdc++.h>
using namespace std;
long long n, m, l, o, kol, q, w;
string k, k1;
char s;
int main() {
  cin >> n >> s >> m;
  while (true) {
    k = "";
    if (n < 10) {
      k = "0";
    }
    k = k + to_string(n);
    if (m < 10) {
      k = k + "0";
    }
    k = k + to_string(m);
    k1 = k;
    reverse(k.begin(), k.end());
    if (k == k1) {
      cout << kol;
      return 0;
    }
    kol++;
    m++;
    n += (m / 60);
    m = m % 60;
    if (n == 24) {
      n = 0;
    }
  }
}
